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

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


     * @param wadl the WADL as String
     * @return the <code>UnitActionPackage</code>
     * @throws XmlException if an error ocurrs.
     */
    public static UnitActionPackage parseWADL(final String wadl) throws XmlException {
        ApplicationDocument applicationDocument = ApplicationDocument.Factory.parse(wadl);
        Application application = applicationDocument.getApplication();
        return Converter.convertWADLtoUnitActionPackage(application);
    }
View Full Code Here


public class WADLGenerator {   
    public static String generateWADLForMashupRESTService(String myCocktailPath, int mashupId) throws DAOException, IOException {
        Mashup mashup = getMashup(mashupId);
       
        ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
        Application application = applicationDocument.addNewApplication();
        Resources resources = application.addNewResources();
        resources.setBase(myCocktailPath);
       
        Resource resource = resources.addNewResource();
        resource.setPath("RESTService/mashupId="+mashupId);
       
        addResource(resource, "json""format=json",  mashup, "application/json");
        addResource(resource, "xml",   "format=xml",   mashup, "application/xml");
        addResource(resource, "jsonp", "format=jsonp", mashup, "application/javascript");
       
        return applicationDocument.xmlText(new XmlOptions().setSavePrettyPrint());
    }
View Full Code Here

    }
   
    public static String generateWADLForMashupRESTServiceJSON(String myCocktailPath, int mashupId) throws DAOException, IOException {
        Mashup mashup = getMashup(mashupId);
       
        ApplicationDocument applicationDocument = ApplicationDocument.Factory.newInstance();
        Application application = applicationDocument.addNewApplication();
        Resources resources = application.addNewResources();
        resources.setBase(myCocktailPath);
       
        Resource resource = resources.addNewResource();
        resource.setPath("RESTService/mashupId="+mashupId);
       
        addMethod(resource.addNewMethod(), "json", mashup, "application/json");
       
        return applicationDocument.xmlText(new XmlOptions().setSavePrettyPrint());
    }
View Full Code Here

          || !element.getNamespaceURI().equals( Constants.WADL11_NS ) )
      {
        throw new Exception( "Document is not a WADL application with " + Constants.WADL11_NS + " namespace" );
      }

      ApplicationDocument applicationDocument = ( ApplicationDocument )xmlObject
          .changeType( ApplicationDocument.type );
      application = applicationDocument.getApplication();

      resourcesList = application.getResourcesList();

      service.setName( getFirstTitle( application.getDocList(), service.getName() ) );
View Full Code Here

        return m;
    }

    try
    {
      ApplicationDocument applicationDocument = loadReferencedWadl( href );
      if( applicationDocument != null )
      {
        int ix = href.lastIndexOf( '#' );
        if( ix > 0 )
          href = href.substring( ix + 1 );
View Full Code Here

    {
      Application app = application;

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

      if( app != null )
      {
        int ix = href.lastIndexOf( '#' );
View Full Code Here

    {
      Application app = application;

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

      if( app != null )
      {
        int ix = href.lastIndexOf( '#' );
View Full Code Here

        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;
        }
View Full Code Here

  private ApplicationDocument loadReferencedWadl( String id ) throws URISyntaxException, XmlException, IOException
  {
    int ix = id.indexOf( '#' );
    if( ix != -1 )
      id = id.substring( 0, ix );
    ApplicationDocument applicationDocument = refCache.get( id );

    if( applicationDocument == null )
    {
      URI uri = new URI( id );
      applicationDocument = ApplicationDocument.Factory.parse( uri.toURL() );
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 ) );
      }
    }

    if( !isWADL11 )
    {
      XmlOptions options = new XmlOptions();
      StringToStringMap subst = new StringToStringMap();
      subst.put( Constants.WADL11_NS, Constants.WADL10_NS );
      options.setLoadSubstituteNamespaces( subst );
      try
      {
        // return XmlObject.Factory.parse( applicationDocument.xmlText(),
        // options );
        return XmlUtils.createXmlObject( applicationDocument.xmlText(), options );
      }
      catch( XmlException e )
      {
        e.printStackTrace();
      }
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.