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

Examples of net.java.dev.wadl.x2009.x02.MethodDocument.Method


  }

  public XmlObject generateWadl()
  {
    ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
    Application application = applicationDocument.addNewApplication();

    createDoc( application.addNewDoc(), restService );

    Resources resources = application.addNewResources();

    // use first endpoint for now -> this should be configurable
    String basePath = restService.getBasePath();
    String[] endpoints = restService.getEndpoints();
    if( endpoints.length > 0 )
      basePath = endpoints[0] + basePath;

    resources.setBase( basePath );

    for( int c = 0; c < restService.getOperationCount(); c++ )
    {
      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 ) );
      }
    }
View Full Code Here


public class WadlTestCase extends TestCase
{
  public void testWadl() throws Exception
  {
    ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
    Application application = applicationDocument.addNewApplication();
  }
View Full Code Here

public class WadlTest {

    @Test
    public void testWadl() throws Exception {
        ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
        Application application = applicationDocument.addNewApplication();
        assertNotNull(application);
    }
View Full Code Here

        if (!StringUtils.hasContent(href)) {
            return representation;
        }

        try {
            Application app = application;

            if (!href.startsWith("#")) {
                ApplicationDocument applicationDocument = loadReferencedWadl(href);
                app = applicationDocument.getApplication();
            }
View Full Code Here

        if (!StringUtils.hasContent(href)) {
            return param;
        }

        try {
            Application app = application;

            if (!href.startsWith("#")) {
                ApplicationDocument applicationDocument = loadReferencedWadl(href);
                app = applicationDocument.getApplication();
            }
View Full Code Here

        this.restService = restService;
    }

    public XmlObject generateWadl() {
        ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
        Application application = applicationDocument.addNewApplication();

        createDoc(application.addNewDoc(), restService);

        Resources resources = application.addNewResources();

        // use first endpoint for now -> this should be configurable
        String basePath = restService.getBasePath();
        String[] endpoints = restService.getEndpoints();
        if (endpoints.length > 0) {
            basePath = endpoints[0] + basePath;
        }

        resources.setBase(basePath);

        for (int c = 0; c < restService.getOperationCount(); c++) {
            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));
            }
        }
View Full Code Here

    }

    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 )
    {
View Full Code Here

            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

TOP

Related Classes of net.java.dev.wadl.x2009.x02.MethodDocument.Method

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.