Esempio n. 1
0
  public Object call(
      String cfcPath,
      String id,
      String functionName,
      Struct arguments,
      boolean cfcPeristent,
      Object defaultValue)
      throws PageException {
    DevNullOutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
    String requestURI = toRequestURI(cfcPath);

    PageContext oldPC = ThreadLocalPageContext.get();
    PageContextImpl pc =
        ThreadUtil.createPageContext(
            config, os, "localhost", requestURI, "", null, null, null, null);
    pc.setRequestTimeout(999999999999999999L);
    try {
      ThreadLocalPageContext.register(pc);
      Component cfc = getCFC(pc, requestURI, cfcPath, id, cfcPeristent);
      if (cfc.containsKey(functionName)) {
        return cfc.callWithNamedValues(pc, functionName, arguments);
      }
    } finally {
      CFMLFactory factory = config.getFactory();
      factory.releasePageContext(pc);
      ThreadLocalPageContext.register(oldPC);
    }
    return defaultValue;
  }
Esempio n. 2
0
  @Override
  protected Object invokeMethod(MessageContext mc, Method method, Object trg, Object[] args)
      throws Exception {
    PageContext pc = (PageContext) mc.getProperty(Constants.PAGE_CONTEXT);
    Component c = (Component) mc.getProperty(Constants.COMPONENT);

    RPCServer server = RPCServer.getInstance(pc.getId(), pc.getServletContext());
    TypeMapping tm = server.getEngine().getTypeMappingRegistry().getDefaultTypeMapping();

    return AxisCaster.toAxisType(tm, c.call(pc, method.getName(), toRailoType(pc, args)), null);
  }
Esempio n. 3
0
  public static boolean isCastableTo(short type, String strType, Object o) {
    switch (type) {
      case CFTypes.TYPE_ANY:
        return true;
      case CFTypes.TYPE_STRING:
        return isCastableToString(o);
      case CFTypes.TYPE_BOOLEAN:
        return isCastableToBoolean(o);
      case CFTypes.TYPE_NUMERIC:
        return isCastableToNumeric(o);
      case CFTypes.TYPE_STRUCT:
        return isCastableToStruct(o);
      case CFTypes.TYPE_ARRAY:
        return isCastableToArray(o);
      case CFTypes.TYPE_QUERY:
        return isQuery(o);
      case CFTypes.TYPE_DATETIME:
        return isDateAdvanced(o, true);
      case CFTypes.TYPE_VOID:
        return isVoid(o); // Caster.toVoid(o,Boolean.TRUE)!=Boolean.TRUE;
      case CFTypes.TYPE_BINARY:
        return isCastableToBinary(o, true);
      case CFTypes.TYPE_TIMESPAN:
        return Caster.toTimespan(o, null) != null;
      case CFTypes.TYPE_UUID:
        return isUUId(o);
      case CFTypes.TYPE_GUID:
        return isGUId(o);
      case CFTypes.TYPE_VARIABLE_NAME:
        return isVariableName(o);
      case CFTypes.TYPE_XML:
        return isXML(o);
    }

    if (o instanceof Component) {
      Component comp = ((Component) o);
      return comp.instanceOf(strType);
    }
    if (isArrayType(strType) && isArray(o)) {
      String t = strType.substring(0, strType.length() - 2);
      Array arr = Caster.toArray(o, null);
      if (arr != null) {
        Iterator it = arr.valueIterator();
        while (it.hasNext()) {
          if (!isCastableTo(type, t, it.next())) return false;
        }
        return true;
      }
    }

    return false;
  }
 private Serializable toIdentifier(Serializable id) {
   if (id instanceof Component) {
     HashMap<String, String> map = new HashMap<String, String>();
     Component cfc = (Component) id;
     ComponentScope scope = cfc.getComponentScope();
     railo.runtime.component.Property[] props = HibernateUtil.getIDProperties(cfc, true, true);
     String name, value;
     for (int i = 0; i < props.length; i++) {
       name = props[i].getName();
       value = CommonUtil.toString(scope.get(CommonUtil.createKey(name), null), null);
       map.put(name, value);
     }
     return map;
   }
   return id;
 }
Esempio n. 5
0
 private Object call(
     Component app, PageContext pc, Collection.Key eventName, Object[] args, boolean catchAbort)
     throws PageException {
   try {
     return app.call(pc, eventName, args);
   } catch (PageException pe) {
     if (Abort.isSilentAbort(pe)) {
       if (catchAbort) return Boolean.FALSE;
       throw pe;
     }
     throw new ModernAppListenerException(pe, eventName.getString());
   }
 }
Esempio n. 6
0
  public static boolean isCastableTo(String type, Object o, boolean alsoPattern) {

    type = StringUtil.toLowerCase(type).trim();
    if (type.length() > 2) {
      char first = type.charAt(0);
      switch (first) {
        case 'a':
          if (type.equals("any")) {
            return true;
          } else if (type.equals("array")) {
            return isCastableToArray(o);
          }
          break;
        case 'b':
          if (type.equals("boolean") || type.equals("bool")) {
            return isCastableToBoolean(o);
          } else if (type.equals("binary")) {
            return isCastableToBinary(o, true);
          } else if (type.equals("base64")) {
            return Caster.toBase64(o, null) != null;
          }
          break;
        case 'c':
          if (alsoPattern && type.equals("creditcard")) {
            return Caster.toCreditCard(o, null) != null;
          }
          break;
        case 'd':
          if (type.equals("date")) {
            return isDateAdvanced(o, true);
          } else if (type.equals("datetime")) {
            return isDateAdvanced(o, true);
          } else if (type.equals("double")) {
            return isCastableToNumeric(o);
          } else if (type.equals("decimal")) {
            return Caster.toDecimal(o, null) != null;
          }
          break;
        case 'e':
          if (type.equals("eurodate")) {
            return isDateAdvanced(o, true);
          } else if (alsoPattern && type.equals("email")) {
            return Caster.toEmail(o, null) != null;
          }
          break;
        case 'f':
          if (type.equals("float")) {
            return isCastableToNumeric(o);
          }
          break;
        case 'g':
          if (type.equals("guid")) {
            return isGUId(o);
          }
          break;
        case 'i':
          if (type.equals("integer") || type.equals("int")) {
            return isCastableToNumeric(o);
          }
          break;
        case 'l':
          if (type.equals("long")) {
            return isCastableToNumeric(o);
          }
          break;
        case 'n':
          if (type.equals("numeric")) {
            return isCastableToNumeric(o);
          } else if (type.equals("number")) {
            return isCastableToNumeric(o);
          }
          break;
        case 'o':
          if (type.equals("object")) {
            return true;
          } else if (type.equals("other")) {
            return true;
          }
          break;
        case 'p':
          if (alsoPattern && type.equals("phone")) {
            return Caster.toPhone(o, null) != null;
          }
          break;
        case 'q':
          if (type.equals("query")) {
            return isQuery(o);
          }
          break;
        case 's':
          if (type.equals("string")) {
            return isCastableToString(o);
          } else if (type.equals("struct")) {
            return isCastableToStruct(o);
          } else if (type.equals("short")) {
            return isCastableToNumeric(o);
          } else if (alsoPattern && (type.equals("ssn") || type.equals("social_security_number"))) {
            return Caster.toSSN(o, null) != null;
          }
          break;
        case 't':
          if (type.equals("timespan")) {
            return Caster.toTimespan(o, null) != null;
          }
          if (type.equals("time")) {
            return isDateAdvanced(o, true);
          }
          if (alsoPattern && type.equals("telephone")) {
            return Caster.toPhone(o, null) != null;
          }
        case 'u':
          if (type.equals("uuid")) {
            return isUUId(o);
          }
          if (type.equals("usdate")) {
            return isDateAdvanced(o, true);
            // return DateCaster.toDate(o,pc.getTimeZone());
          }
          if (alsoPattern && type.equals("url")) {
            return Caster.toURL(o, null) != null;
          }
          break;
        case 'v':
          if (type.equals("variablename")) {
            return isVariableName(o);
          } else if (type.equals("void")) {
            return isVoid(o); // Caster.toVoid(o,Boolean.TRUE)!=Boolean.TRUE;
          } else if (type.equals("variable_name")) {
            return isVariableName(o);
          } else if (type.equals("variable-name")) {
            return isVariableName(o);
          }
          break;
        case 'x':
          if (type.equals("xml")) {
            return isXML(o);
          }
          break;
        case 'z':
          if (alsoPattern && (type.equals("zip") || type.equals("zipcode"))) {
            return Caster.toZip(o, null) != null;
          }
          break;
      }
    }
    if (o instanceof Component) {
      Component comp = ((Component) o);
      return comp.instanceOf(type);
    }
    if (isArrayType(type) && isArray(o)) {
      String t = type.substring(0, type.length() - 2);
      Array arr = Caster.toArray(o, null);
      if (arr != null) {
        Iterator it = arr.valueIterator();
        while (it.hasNext()) {
          if (!isCastableTo(t, it.next(), alsoPattern)) return false;
        }
        return true;
      }
    }
    return false;
  }
Esempio n. 7
0
 void checkExistent(PageContext pc, Component cfc) throws ORMException {
   if (!cfcs.containsKey(id(HibernateCaster.getEntityName(cfc))))
     throw new ORMException(
         this, "there is no mapping definition for component [" + cfc.getAbsName() + "]");
 }