Package play.exceptions

Examples of play.exceptions.NoRouteFoundException


        String[] names = Java.parameterNames(actionMethod);
        if (param instanceof Object[]) {
          // too many parameters versus action, possibly a developer
          // error. we must warn him.
          if (names.length < ((Object[]) param).length) {
            throw new NoRouteFoundException(action, null);
          }
          Annotation[] annos = actionMethod.getAnnotations();
          for (int i = 0; i < ((Object[]) param).length; i++) {
            if (((Object[]) param)[i] instanceof Router.ActionDefinition && ((Object[]) param)[i] != null) {
              Unbinder.unBind(args, ((Object[]) param)[i].toString(), i < names.length ? names[i] : "", annos);
View Full Code Here


          getActionParamCache().put(action, targetParamNames);
        }
        // too many parameters versus action, possibly a developer
        // error. we must warn him.
        if (targetParamNames.length < params.length) {
          throw new NoRouteFoundException(action, null);
        }

        String k = action;
        for (String p : targetParamNames) {
          k += "_" + p;
View Full Code Here

                    + LocalVariablesNamesTracer.computeMethodHash(actionMethod.getParameterTypes())).get(null);
        if (param instanceof Object[]) {
          // too many parameters versus action, possibly a developer
          // error. we must warn him.
          if (names.length < ((Object[]) param).length) {
            throw new NoRouteFoundException(action, null);
          }
          for (int i = 0; i < ((Object[]) param).length; i++) {
            if (((Object[]) param)[i] instanceof Router.ActionDefinition && ((Object[]) param)[i] != null) {
              Unbinder.unBind(r, ((Object[]) param)[i].toString(), i < names.length ? names[i] : "");
            } else if (isSimpleParam(actionMethod.getParameterTypes()[i])) {
              if (((Object[]) param)[i] != null) {
                Unbinder.unBind(r, ((Object[]) param)[i].toString(), i < names.length ? names[i] : "");
              }
            } else {
              Unbinder.unBind(r, ((Object[]) param)[i], i < names.length ? names[i] : "");
            }
          }
        }
        Router.ActionDefinition def = Router.reverse(action, r);
        if (absolute) {
          def.absolute();
        }

        // if (template.template.name.endsWith(".html") ||
        // template.template.name.endsWith(".xml")) {
        def.url = def.url.replace("&", "&amp;");
        // }
        return def;
      } catch (ActionNotFoundException e) {
        throw new NoRouteFoundException(action, null);
      }
    } catch (Exception e) {
      if (e instanceof PlayException) {
        throw (PlayException) e;
      }
View Full Code Here

     */
    protected static void redirectToStatic(String file) {
        try {
            VirtualFile vf = Play.getVirtualFile(file);
            if (vf == null || !vf.exists()) {
                throw new NoRouteFoundException(file);
            }
            throw new RedirectToStatic(Router.reverse(Play.getVirtualFile(file)));
        } catch (NoRouteFoundException e) {
            StackTraceElement element = PlayException.getInterestingStrackTraceElement(e);
            if (element != null) {
                throw new NoRouteFoundException(file, Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
            } else {
                throw e;
            }
        }
    }
View Full Code Here

                    throw new Redirect(actionDefinition.toString(), permanent);
                }
            } catch (NoRouteFoundException e) {
                StackTraceElement element = PlayException.getInterestingStrackTraceElement(e);
                if (element != null) {
                    throw new NoRouteFoundException(action, newArgs, Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
                } else {
                    throw e;
                }
            }
        } catch (Exception e) {
View Full Code Here

        return reverse(file, false);
    }

    public static String reverse(VirtualFile file, boolean absolute) {
        if (file == null || !file.exists()) {
            throw new NoRouteFoundException("File not found (" + file + ")");
        }
        String path = file.relativePath();
        path = path.substring(path.indexOf("}") + 1);
        for (Route route : routes) {
            String staticDir = route.staticDir;
            if (staticDir != null) {
                if (!staticDir.startsWith("/")) {
                    staticDir = "/" + staticDir;
                }
                if (!staticDir.equals("/") && !staticDir.endsWith("/")) {
                    staticDir = staticDir + "/";
                }
                if (path.startsWith(staticDir)) {
                    String to = route.path + path.substring(staticDir.length());
                    if (to.endsWith("/index.html")) {
                        to = to.substring(0, to.length() - "/index.html".length() + 1);
                    }
                    if (absolute) {
                        boolean isSecure = Http.Request.current() == null ? false : Http.Request.current().secure;
                        String base = getBaseUrl();
                        if (!StringUtils.isEmpty(route.host)) {
                            // Compute the host
                          int port = Http.Request.current() == null ? 80 : Http.Request.current().get().port;
                          String host = (port != 80 && port != 443) ? route.host + ":" + port : route.host;
                          to = (isSecure ? "https://" : "http://") + host + to;
                        } else {
                            to = base + to;
                        }
                    }
                    return to;
                }
            }
        }
        throw new NoRouteFoundException(file.relativePath());
    }
View Full Code Here

        throw new NoRouteFoundException(file.relativePath());
    }

    public static String reverseWithCheck(String name, VirtualFile file, boolean absolute) {
        if (file == null || !file.exists()) {
            throw new NoRouteFoundException(name + " (file not found)");
        }
        return reverse(file, absolute);
    }
View Full Code Here

                        return actionDefinition;
                    }
                }
            }
        }
        throw new NoRouteFoundException(action, args);
    }
View Full Code Here

                            if(((Object[])param).length == 1 && ((Object[])param)[0] instanceof Map) {
                                r = (Map<String,Object>)((Object[])param)[0];
                            } else {
                                // too many parameters versus action, possibly a developer error. we must warn him.
                                if (names.length < ((Object[]) param).length) {
                                    throw new NoRouteFoundException(action, null);
                                }
                                for (int i = 0; i < ((Object[]) param).length; i++) {
                                    if (((Object[]) param)[i] instanceof Router.ActionDefinition && ((Object[]) param)[i] != null) {
                                        Unbinder.unBind(r, ((Object[]) param)[i].toString(), i < names.length ? names[i] : "", actionMethod.getAnnotations());
                                    } else if (isSimpleParam(actionMethod.getParameterTypes()[i])) {
                                        if (((Object[]) param)[i] != null) {
                                            Unbinder.unBind(r, ((Object[]) param)[i].toString(), i < names.length ? names[i] : "", actionMethod.getAnnotations());
                                        }
                                    } else {
                                        Unbinder.unBind(r, ((Object[]) param)[i], i < names.length ? names[i] : "", actionMethod.getAnnotations());
                                    }
                                }
                            }
                        }
                        Router.ActionDefinition def = Router.reverse(action, r);
                        if (absolute) {
                            def.absolute();
                        }
                        if (template.template.name.endsWith(".xml")) {
                            def.url = def.url.replace("&", "&amp;");
                        }
                        return def;
                    } catch (ActionNotFoundException e) {
                        throw new NoRouteFoundException(action, null);
                    }
                } catch (Exception e) {
                    if (e instanceof PlayException) {
                        throw (PlayException) e;
                    }
View Full Code Here

                if (doBodyLines.contains(stackTraceElement.getLineNumber())) {
                    throw new DoBodyException(e);
                } else if (e instanceof TagInternalException) {
                    throw (TagInternalException) cleanStackTrace(e);
                } else if (e instanceof NoRouteFoundException) {
                    NoRouteFoundException ex = (NoRouteFoundException) cleanStackTrace(e);
                    if (ex.getFile() != null) {
                        throw new NoRouteFoundException(ex.getFile(), this, this.linesMatrix.get(stackTraceElement.getLineNumber()));
                    }
                    throw new NoRouteFoundException(ex.getAction(), ex.getArgs(), this, this.linesMatrix.get(stackTraceElement.getLineNumber()));
                } else if (e instanceof TemplateExecutionException) {
                    throw (TemplateExecutionException) cleanStackTrace(e);
                } else {
                    throw new TemplateExecutionException(this, this.linesMatrix.get(stackTraceElement.getLineNumber()), e.getMessage(), cleanStackTrace(e));
                }
View Full Code Here

TOP

Related Classes of play.exceptions.NoRouteFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.