protected boolean dispatch() throws IOException { UrlParser up = new UrlParser(uri.getPath()); String apps = up.next(); String application; if (apps.equalsIgnoreCase("apps")) application = up.next(); else application = apps; String model = up.next(); if (model.length() == 0) return false; if (checkRhoExtensions(application, model)) return true; Properties reqHash = new Properties(); String actionid = up.next(); String actionnext = up.next(); if (actionid.length() > 0) { if (actionid.length() > 2 && actionid.charAt(0) == '{' && actionid.charAt(actionid.length() - 1) == '}') { reqHash.setProperty("id", actionid); reqHash.setProperty("action", actionnext); } else { reqHash.setProperty("id", actionnext); reqHash.setProperty("action", actionid); } } reqHash.setProperty("application", application); reqHash.setProperty("model", model); reqHash.setProperty("request-method", this.method); reqHash.setProperty("request-uri", uri.getPath()); reqHash.setProperty("request-query", uri.getQueryString()); if (postData != null && postData.size() > 0) { log(postData.toString()); reqHash.setProperty("request-body", postData.toString()); } RubyValue res = RhoRuby.processRequest(reqHash, reqHeaders, resHeaders); processResponse(res); return true; }
protected boolean dispatch() throws IOException { // LOG.INFO("dispatch start : " + uri.getPath()); UrlParser up = new UrlParser(uri.getPath()); String apps = up.next(); String application; if (apps.equalsIgnoreCase("apps")) application = up.next(); else application = apps; String model = up.next(); if (model == null || model.length() == 0) return false; if (checkRhoExtensions(application, model)) return true; // Convert CamelCase to underscore_case StringBuffer cName = new StringBuffer(); byte[] modelname = model.getBytes(); char ch; for (int i = 0; i != model.length(); ++i) { if (modelname[i] >= (byte) 'A' && modelname[i] <= (byte) 'Z') { ch = (char) (modelname[i] + 0x20); if (i != 0) cName.append('_'); } else ch = (char) modelname[i]; cName.append(ch); } String controllerName = cName.toString(); String strCtrl = "apps/" + application + '/' + model + '/' + controllerName + "_controller"; if (RhoSupport.findClass(strCtrl) == null) { strCtrl = "apps/" + application + '/' + model + '/' + "controller"; if (RhoSupport.findClass(strCtrl) == null) return false; } Properties reqHash = new Properties(); String actionid = up.next(); String actionnext = up.next(); if (actionid != null && actionid.length() > 0) { if (actionid.length() > 6 && actionid.startsWith("%7B") && actionid.endsWith("%7D")) actionid = "{" + actionid.substring(3, actionid.length() - 3) + "}"; if (actionid.length() > 2 && actionid.charAt(0) == '{' && actionid.charAt(actionid.length() - 1) == '}') { reqHash.setProperty("id", actionid); reqHash.setProperty("action", actionnext); } else { reqHash.setProperty("id", actionnext); reqHash.setProperty("action", actionid); } } reqHash.setProperty("application", application); reqHash.setProperty("model", model); doDispatch(reqHash, null); if (actionid != null && actionid.length() > 2 && actionid.charAt(0) == '{' && actionid.charAt(actionid.length() - 1) == '}') SyncThread.getInstance().addobjectnotify_bysrcname(model, actionid); return true; }