示例#1
0
  private ResourceTypeDocument.ResourceType resolveResource(String id) {
    for (ResourceTypeDocument.ResourceType resourceType : application.getResourceTypeList()) {
      if (resourceType.getId().equals(id)) {
        return resourceType;
      }
    }

    try {
      ApplicationDocument applicationDocument = loadReferencedWadl(id);
      if (applicationDocument != null) {
        int ix = id.lastIndexOf('#');
        if (ix > 0) {
          id = id.substring(ix + 1);
        }

        for (ResourceTypeDocument.ResourceType resourceType :
            applicationDocument.getApplication().getResourceTypeList()) {
          if (resourceType.getId().equals(id)) {
            return resourceType;
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
示例#2
0
  private void initResourceFromWadlResource(RestResource newResource, Resource resource) {
    for (Param param : resource.getParamList()) {
      param = resolveParameter(param);
      if (param != null) {
        String nm = param.getName();
        RestParamProperty prop =
            newResource.hasProperty(nm) ? newResource.getProperty(nm) : newResource.addProperty(nm);

        initParam(param, prop);
      }
    }

    for (Method method : resource.getMethodList()) {
      method = resolveMethod(method);
      initMethod(newResource, method);
    }

    List<?> types = resource.getType();
    if (types != null && types.size() > 0) {
      for (Object obj : types) {
        ResourceTypeDocument.ResourceType type = resolveResource(obj.toString());
        if (type != null) {
          for (Method method : type.getMethodList()) {
            method = resolveMethod(method);
            RestMethod restMethod = initMethod(newResource, method);

            for (Param param : type.getParamList()) {
              param = resolveParameter(param);
              if (param != null) {
                String nm = param.getName();
                RestParamProperty prop =
                    restMethod.hasProperty(nm)
                        ? restMethod.getProperty(nm)
                        : restMethod.addProperty(nm);

                initParam(param, prop);
              }
            }
          }
        }
      }
    }
  }