Package com.google.code.apis.rest.client.Wadl

Examples of com.google.code.apis.rest.client.Wadl.ResourceNode


    else if (parentNode instanceof ResourcesNode) {
      allResources = ((ResourcesNode) parentNode).getAllResources();
    }    
    Iterator allResourcesIterator = allResources.iterator();
    while (allResourcesIterator.hasNext()) {     
      final ResourceNode resource = (ResourceNode) allResourcesIterator.next();
      ResourceItem resourceItem = new ResourceItem(resource, parentNode, parentTreeItem);
      final TreeItem resourceTreeItem = new TreeItem(resourceItem);     
      resourceTreeItem.setUserObject(WadlXml.resourceNode);
      parentTreeItem.addItem(resourceTreeItem);
      resourceTreeItem.setState(SettingsDialog.treeItemsAlwaysOpen);    
                 
      String requestString = "";
      if (resource.getApplication() != null) {
        requestString = resource.getApplication().getAnalyzer().getRequestString();
      }
      // parameters     
      ParamItem.listParams(
          resource,
          resourceTreeItem,
          requestString);
     
      // methods     
      MethodItem.listMethods(resource, resourceTreeItem, requestString);    
     
      // resource    
      listResources((Object) resource, resourceTreeItem);    
     
      // close resource item
      GenericClosingItem resourceCloseItem = new GenericClosingItem(WadlXml.resourceNode);
      TreeItem resourceCloseTreeItem = new TreeItem(resourceCloseItem);
      resourceCloseTreeItem.setUserObject(WadlXml.resourceNode);
      parentTreeItem.addItem(resourceCloseTreeItem);
    }
   
   if (!WadlTreeRoot.containsButton(buttonTreeItems, ApplicationItem.button + WadlXml.resourceNode)) {
      // add resource button
      HorizontalPanel addResourcePanel = new HorizontalPanel();           
      Button addResourceButton = new Button(GuiFactory.strings.addResource());
      addResourceButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {    
          if (parentNode instanceof ResourceNode) {
            ((ResourceNode) parentNode).addResource(new ResourceNode(GuiFactory.strings.newResource(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
          }
          else if (parentNode instanceof ResourcesNode) {
            ((ResourcesNode) parentNode).addResource(new ResourceNode(GuiFactory.strings.newResource(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
          }                     
          listResources(parentNode, parentTreeItem);       
        }
      });
      addResourcePanel.add(addResourceButton);
View Full Code Here


    else if (parent instanceof ResourceNode) {
      allResources = ((ResourceNode) parent).getAllResources();
    }
    Iterator allResourcesIterator = allResources.iterator();         
    while(allResourcesIterator.hasNext()) {
      ResourceNode resource = (ResourceNode) allResourcesIterator.next();
      if (resource.getAllMethods() != null) {
        Vector allMethods = resource.getAllMethods();
        Iterator allMethodsIterator = allMethods.iterator();
        while(allMethodsIterator.hasNext()) {
          MethodNode method = (MethodNode) allMethodsIterator.next();
          if (id.equals(method.getHref().substring(1))) {
            ResourceNode resourceNode = ((ResourceNode) method.getParent());
            String name = resourceNode.getPath();
            String absoluteAddress = resourceNode.getAbsolutePath() + resourceNode.getPath();                 
            // check if we have a template parameter
            while (resource.getPath().matches(Analyzer.templateParamRegExp)) {
              // don't confuse: param is from the WADL, parameter is for code generation
              String path = resource.getPath();       
              int indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
View Full Code Here

    String httpMethodName = thisRequestsMethod.getName();  
    String absoluteAddress = null;
    String name = null;
    Object thisRequestsMethodsParent = (Object) thisRequestsMethod.getParent();
    if (thisRequestsMethodsParent instanceof ResourceNode) {
      ResourceNode resource = (ResourceNode) thisRequestsMethodsParent;
      name = resource.getPath();
      absoluteAddress = resource.getAbsolutePath() + resource.getPath();     
      // check if we have template parameters
      while (resource.getPath().matches(Analyzer.templateParamRegExp)) {
        // don't confuse: param is from the WADL, parameter is for code generation
        String path = resource.getPath();       
        int indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
        int indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);       
        while(indexOfOpen >= 0 &&
            indexOfClose > 0 &&
            indexOfOpen < indexOfClose) {         
          String templateParamName = path.substring(indexOfOpen + 1, indexOfClose);
          // from all the potential params find the one that matches the template {name}
          Vector templateParams = resource.getAllParams();
          Iterator templateParamsIterator = templateParams.iterator();         
          ParamNode templateParam = null;
          if (templateParamsIterator.hasNext()) {
            templateParam = (ParamNode) templateParamsIterator.next();
          }
          while(!templateParam.getName().equals(templateParamName)) {
            templateParam = (ParamNode) templateParamsIterator.next();
          }
          // now generate the code generation parameter      
          Parameter templateParameter = new Parameter(
              templateParamName + SettingsDialog.templateSuffix,
              templateParam.getType(),
              Parameter.accessPrivate,
              templateParam.getIsRequired(),              
              language,
              true);
          variables.insertElementAt(templateParameter, 0);
         
          path = path.substring(indexOfClose + 1);
          indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
          indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);         
        }
        if (resource.getParent().getParent() instanceof ResourceNode) {
          resource = (ResourceNode) resource.getParent().getParent();
        }
        else {
          break;
        }
      }           
View Full Code Here

      }
    } 
    // do this every time
    Iterator allResourcesIterator = allResources.iterator();
    while(allResourcesIterator.hasNext()) {
      ResourceNode resource = (ResourceNode) allResourcesIterator.next();     
      if (!resource.getAllMethods().isEmpty()) {
        Vector allMethods = resource.getAllMethods();
        Iterator allMethodsIterator = allMethods.iterator();
        while(allMethodsIterator.hasNext()) {
          MethodNode method = (MethodNode) allMethodsIterator.next();         
          if (method.getRequest() != null) {
            RequestNode request = method.getRequest();                   
            if (!request.getAllParams().isEmpty()) {            
              examineParams(request.getAllParams());
              return;
            }
          }         
        }
      }   
      // recursive call for inner resources (a resource in a resource)
      addParamsToListBox(resource.getAllResources(), false);     
    }
  }  
View Full Code Here

TOP

Related Classes of com.google.code.apis.rest.client.Wadl.ResourceNode

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.