Package net.java.dev.wadl.x2009.x02

Examples of net.java.dev.wadl.x2009.x02.ApplicationDocument


            resources.addNewResource().set(generateWadlResource(restService.getOperationAt(c)));
        }

        String[] namespaces = InferredSchemaManager.getInferredSchema(restService).getNamespaces();
        if (namespaces.length > 0) {
            Grammars grammars = application.addNewGrammars();
            for (String namespace : namespaces) {
                grammars.addNewInclude().setHref(InferredSchemaManager.filenameForNamespace(namespace));
            }
        }

        if (!isWADL11) {
            XmlOptions options = new XmlOptions();
View Full Code Here


    docConfig.getDomNode().appendChild( docConfig.getDomNode().getOwnerDocument().createTextNode( description ) );
  }

  private void generateWadlMethod( Resource resourceConfig, RestMethod restMethod )
  {
    Method methodConfig = resourceConfig.addNewMethod();
    createDoc( methodConfig.addNewDoc(), restMethod );
    methodConfig.setName( restMethod.getMethod().toString() );
    methodConfig.setId( restMethod.getName() );
    Request requestConfig = methodConfig.addNewRequest();

    Map<String, RestParamProperty> defaultParams = new HashMap<String, RestParamProperty>();
    for( RestParamProperty defaultParam : restMethod.getResource().getDefaultParams() )
      defaultParams.put( defaultParam.getName(), defaultParam );

    RestParamsPropertyHolder params = restMethod.getParams();
    for( int c = 0; c < params.size(); c++ )
    {
      RestParamProperty param = params.getPropertyAt( c );
      if( !defaultParams.containsKey( param.getName() ) || !param.equals( defaultParams.get( param.getName() ) ) )
        generateParam( requestConfig.addNewParam(), param );
    }

    if( restMethod.hasRequestBody() )
    {
      for( RestRepresentation representation : restMethod.getRepresentations( RestRepresentation.Type.REQUEST, null ) )
      {
        generateRepresentation( requestConfig.addNewRepresentation(), representation );
      }
    }

    Map<String, Response> responses = new HashMap<String, Response>();
    if( !isWADL11 )
      responses.put( null, methodConfig.addNewResponse() );
    for( RestRepresentation representation : restMethod.getRepresentations() )
    {
      Response response;
      if( isWADL11 )
      {
        List<Comparable> status = new ArrayList<Comparable>( ( List<Comparable> )representation.getStatus() );
        Collections.sort( status );
        StringBuilder statusStrBuilder = new StringBuilder();
        for( Object o : status )
          statusStrBuilder.append( o ).append( " " );
        String statusStr = statusStrBuilder.toString();

        if( !responses.containsKey( statusStr ) )
        {
          response = methodConfig.addNewResponse();
          response.setStatus( status );
          responses.put( statusStr, response );
        }
        else
        {
View Full Code Here

        docConfig.setTitle(name);
        docConfig.getDomNode().appendChild(docConfig.getDomNode().getOwnerDocument().createTextNode(description));
    }

    private void generateWadlMethod(Resource resourceConfig, RestMethod restMethod) {
        Method methodConfig = resourceConfig.addNewMethod();
        createDoc(methodConfig.addNewDoc(), restMethod);
        methodConfig.setName(restMethod.getMethod().toString());
        methodConfig.setId(restMethod.getName());
        Request requestConfig = methodConfig.addNewRequest();

        Map<String, RestParamProperty> defaultParams = new HashMap<String, RestParamProperty>();
        for (RestParamProperty defaultParam : restMethod.getResource().getDefaultParams()) {
            defaultParams.put(defaultParam.getName(), defaultParam);
        }

        RestParamsPropertyHolder params = restMethod.getParams();
        for (int c = 0; c < params.size(); c++) {
            RestParamProperty param = params.getPropertyAt(c);
            if (!defaultParams.containsKey(param.getName()) || !param.equals(defaultParams.get(param.getName()))) {
                generateParam(requestConfig.addNewParam(), param);
            }
        }

        if (restMethod.hasRequestBody()) {
            for (RestRepresentation representation : restMethod.getRepresentations(RestRepresentation.Type.REQUEST, null)) {
                generateRepresentation(requestConfig.addNewRepresentation(), representation);
            }
        }

        Map<String, Response> responses = new HashMap<String, Response>();
        if (!isWADL11) {
            responses.put(null, methodConfig.addNewResponse());
        }
        for (RestRepresentation representation : restMethod.getRepresentations()) {
            Response response;
            if (isWADL11) {
                List<Comparable> status = new ArrayList<Comparable>((List<Comparable>) representation.getStatus());
                Collections.sort(status);
                StringBuilder statusStrBuilder = new StringBuilder();
                for (Object o : status) {
                    statusStrBuilder.append(o).append(" ");
                }
                String statusStr = statusStrBuilder.toString();

                if (!responses.containsKey(statusStr)) {
                    response = methodConfig.addNewResponse();
                    response.setStatus(status);
                    responses.put(statusStr, response);
                } else {
                    response = responses.get(statusStr);
                }
View Full Code Here

              // XmlObject obj = XmlObject.Factory.parse(
              // content.replaceFirst( "<(([a-z]+:)?)fault ",
              // "<$1representation " ), options );
              XmlObject obj = XmlUtils.createXmlObject(
                  content.replaceFirst( "<(([a-z]+:)?)fault ", "<$1representation " ), options );
              RepresentationDocument representation = ( RepresentationDocument )obj
                  .changeType( RepresentationDocument.type );
              addRepresentation( response, restMethod, representation.getRepresentation() );
            }
            catch( XmlException e )
            {
            }
          }
View Full Code Here

                            // XmlObject obj = XmlObject.Factory.parse(
                            // content.replaceFirst( "<(([a-z]+:)?)fault ",
                            // "<$1representation " ), options );
                            XmlObject obj = XmlUtils.createXmlObject(
                                    content.replaceFirst("<(([a-z]+:)?)fault ", "<$1representation "), options);
                            RepresentationDocument representation = (RepresentationDocument) obj
                                    .changeType(RepresentationDocument.type);
                            addRepresentation(response, restMethod, representation.getRepresentation());
                        } catch (XmlException e) {
                        }
                    }
                }
            }
View Full Code Here

      else
      {
        response = responses.get( null );
      }

      Representation representationConfig = response.addNewRepresentation();
      generateRepresentation( representationConfig, representation );

      if( !isWADL11 && representation.getType() == RestRepresentation.Type.FAULT )
      {
        Element resp = ( Element )response.getDomNode();
        Element rep = ( Element )representationConfig.getDomNode();
        Element fault = resp.getOwnerDocument().createElementNS( Constants.WADL11_NS, "fault" );

        NamedNodeMap attributes = rep.getAttributes();
        for( int i = 0; i < attributes.getLength(); i++ )
        {
View Full Code Here

                }
            } else {
                response = responses.get(null);
            }

            Representation representationConfig = response.addNewRepresentation();
            generateRepresentation(representationConfig, representation);

            if (!isWADL11 && representation.getType() == RestRepresentation.Type.FAULT) {
                Element resp = (Element) response.getDomNode();
                Element rep = (Element) representationConfig.getDomNode();
                Element fault = resp.getOwnerDocument().createElementNS(Constants.WADL11_NS, "fault");

                NamedNodeMap attributes = rep.getAttributes();
                for (int i = 0; i < attributes.getLength(); i++) {
                    fault.setAttribute(attributes.item(i).getNodeName(), attributes.item(i).getNodeValue());
View Full Code Here

  {
    Method methodConfig = resourceConfig.addNewMethod();
    createDoc( methodConfig.addNewDoc(), restMethod );
    methodConfig.setName( restMethod.getMethod().toString() );
    methodConfig.setId( restMethod.getName() );
    Request requestConfig = methodConfig.addNewRequest();

    Map<String, RestParamProperty> defaultParams = new HashMap<String, RestParamProperty>();
    for( RestParamProperty defaultParam : restMethod.getResource().getDefaultParams() )
      defaultParams.put( defaultParam.getName(), defaultParam );

    RestParamsPropertyHolder params = restMethod.getParams();
    for( int c = 0; c < params.size(); c++ )
    {
      RestParamProperty param = params.getPropertyAt( c );
      if( !defaultParams.containsKey( param.getName() ) || !param.equals( defaultParams.get( param.getName() ) ) )
        generateParam( requestConfig.addNewParam(), param );
    }

    if( restMethod.hasRequestBody() )
    {
      for( RestRepresentation representation : restMethod.getRepresentations( RestRepresentation.Type.REQUEST, null ) )
      {
        generateRepresentation( requestConfig.addNewRepresentation(), representation );
      }
    }

    Map<String, Response> responses = new HashMap<String, Response>();
    if( !isWADL11 )
View Full Code Here

    private void generateWadlMethod(Resource resourceConfig, RestMethod restMethod) {
        Method methodConfig = resourceConfig.addNewMethod();
        createDoc(methodConfig.addNewDoc(), restMethod);
        methodConfig.setName(restMethod.getMethod().toString());
        methodConfig.setId(restMethod.getName());
        Request requestConfig = methodConfig.addNewRequest();

        Map<String, RestParamProperty> defaultParams = new HashMap<String, RestParamProperty>();
        for (RestParamProperty defaultParam : restMethod.getResource().getDefaultParams()) {
            defaultParams.put(defaultParam.getName(), defaultParam);
        }

        RestParamsPropertyHolder params = restMethod.getParams();
        for (int c = 0; c < params.size(); c++) {
            RestParamProperty param = params.getPropertyAt(c);
            if (!defaultParams.containsKey(param.getName()) || !param.equals(defaultParams.get(param.getName()))) {
                generateParam(requestConfig.addNewParam(), param);
            }
        }

        if (restMethod.hasRequestBody()) {
            for (RestRepresentation representation : restMethod.getRepresentations(RestRepresentation.Type.REQUEST, null)) {
                generateRepresentation(requestConfig.addNewRepresentation(), representation);
            }
        }

        Map<String, Response> responses = new HashMap<String, Response>();
        if (!isWADL11) {
View Full Code Here

    return applicationDocument;
  }

  private XmlObject generateWadlResource( RestResource resource )
  {
    Resource resourceConfig = Resource.Factory.newInstance();
    createDoc( resourceConfig.addNewDoc(), resource );
    String path = resource.getPath();
    if( path.startsWith( "/" ) )
      path = path.length() > 1 ? path.substring( 1 ) : "";

    resourceConfig.setPath( path );
    resourceConfig.setId( resource.getName() );

    RestParamsPropertyHolder params = resource.getParams();
    for( int c = 0; c < params.size(); c++ )
    {
      generateParam( resourceConfig.addNewParam(), params.getPropertyAt( c ) );
    }

    for( int c = 0; c < resource.getChildResourceCount(); c++ )
    {
      resourceConfig.addNewResource().set( generateWadlResource( resource.getChildResourceAt( c ) ) );
    }

    for( int c = 0; c < resource.getRestMethodCount(); c++ )
    {
      RestMethod restMethod = resource.getRestMethodAt( c );
View Full Code Here

TOP

Related Classes of net.java.dev.wadl.x2009.x02.ApplicationDocument

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.