Package org.apache.abdera.model

Examples of org.apache.abdera.model.Service


    assertEquals(dateTime.getTime(), now.getTime());
    dateTime = factory.newPublished();
    dateTime.setString(AtomDate.format(now));
    assertEquals(dateTime.getString(), AtomDate.format(now));
    assertEquals(dateTime.getDate(), now);
    Service service = factory.newService();
    assertNotNull(service);
    Source source = factory.newSource();
    assertNotNull(source);
    el = factory.newElement(Constants.NAME);
    assertNotNull(el);
View Full Code Here


 
  private static AppTest INSTANCE = null;
 
  private static Document<Service> init_service_document(String base) {
    try {
      Service service = getFactory().newService();
      Workspace workspace = service.addWorkspace("Test");
      workspace.addCollection("Entries", base + "/collections/entries").setAccept("entry");
      workspace.addCollection("Other", base + "/collections/other").setAccept("text/plain");
      Document<Service> doc = service.getDocument();
      return doc;
    } catch (Exception e) {}
    return null;
  }
View Full Code Here

            Assert.assertEquals(ResponseType.SUCCESS, res.getType());

            // Perform other tests on feed.
            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());       
            Document<Service> serviceDoc = res.getDocument();
            Service service = serviceDoc.getRoot();
            Assert.assertNotNull( service );
            org.apache.abdera.model.Collection collection =  service.getCollection( "workspace", "customers" );
            String title = collection.getTitle();
            Assert.assertEquals("customers", title);
            String href = collection.getHref().toString();
            Assert.assertTrue( href.contains( "customer") );
        } finally {
View Full Code Here

                 */
               
            // Return the Atom service document
            response.setContentType("application/atomsvc+xml; charset=utf-8");
           
            Service service = abderaFactory.newService();
            //service.setText("service");
           
            Workspace workspace = abderaFactory.newWorkspace();
            workspace.setTitle("resource");

            String href = request.getRequestURL().toString();
            href = href.substring(0, href.length() - "/atomsvc".length());
           
            Collection collection = workspace.addCollection("collection", "atom/feed");
            collection.setTitle("entries");
            collection.setAttributeValue("href", href);
            collection.setAccept("entry");
            collection.addCategories().setFixed(false);
           
            workspace.addCollection(collection);

            service.addWorkspace(workspace);

            //FIXME add prettyPrint support
            try {
                service.getDocument().writeTo(response.getOutputStream());
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }

        } else if (path == null || path.length() == 0 || path.equals("/")) {
View Full Code Here

 
  private static AppTest INSTANCE = null;
 
  private static Document<Service> init_service_document(String base) {
    try {
      Service service = getFactory().newService();
      Workspace workspace = service.addWorkspace("Test");
      workspace.addCollection("Entries", base + "/collections/entries").setAccept("entry");
      workspace.addCollection("Other", base + "/collections/other").setAccept("text/plain");
      Document<Service> doc = service.getDocument();
      return doc;
    } catch (Exception e) {}
    return null;
  }
View Full Code Here

    assertEquals(dateTime.getTime(), now.getTime());
    dateTime = factory.newPublished();
    dateTime.setString(AtomDate.format(now));
    assertEquals(dateTime.getString(), AtomDate.format(now));
    assertEquals(dateTime.getDate(), now);
    Service service = factory.newService();
    assertNotNull(service);
    Source source = factory.newSource();
    assertNotNull(source);
    el = factory.newElement(Constants.NAME);
    assertNotNull(el);
View Full Code Here

            int pathIndex = workspaceURL.indexOf( request.getServletPath() );
            if ( -1 != pathIndex ) {
                workspaceURL = workspaceURL.substring( 0, pathIndex ) + "/";
            }

            Service service = abderaFactory.newService();
            //service.setText("service");

            Workspace workspace = abderaFactory.newWorkspace();
            if ( title != null ) {
                workspace.setTitle(title);
            } else {
                workspace.setTitle("workspace");
            }
            workspace.setBaseUri( new IRI( workspaceURL ));

            Collection collection = workspace.addCollection("collection", href );
            Feed feed = getFeed( request );
            if ( feed != null ) {
                String title = feed.getTitle();
                if ( title != null ) {
                    collection.setTitle(title);
                } else {
                    collection.setTitle("entries");
                }
                collection.addAccepts("application/atom+xml");
                collection.addAccepts("application/json");
                List<Category> categories = feed.getCategories();
                if ( categories != null ) {
                    collection.addCategories(categories, false, null);
                } else {
                    collection.addCategories().setFixed(false);
                }

            } else {
                collection.setTitle("entries");

                collection.addAccepts("application/atom+xml");
                collection.addAccepts("application/json");
                collection.addCategories().setFixed(false);
            }
            workspace.addCollection(collection);
            service.addWorkspace(workspace);

            //FIXME add prettyPrint support
            try {
                service.getDocument().writeTo(response.getOutputStream());
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }

        } else if (path == null || path.length() == 0 || path.equals("/")) {
View Full Code Here

    protected abstract WorkspaceManager getWorkspaceManager(
            RequestContext request);

    protected Service getServiceElement(RequestContext request) {
        Service service = abdera.newService();
        for (WorkspaceInfo wi : getWorkspaceManager(request).getWorkspaces(request)) {
            service.addWorkspace(wi.asWorkspaceElement(request));
        }
        return service;
    }
View Full Code Here

    // Perform introspection.  This is an optional step.  If you already
    // know the URI of the APP collection to POST to, you can skip it.
    Document<Service> introspection =
      client.get(
        args[0]).getDocument();
    Service service =
      introspection.getRoot();
    Collection collection =
      service.getCollection(
        args[1],
        args[2]);
    report("The Collection Element", collection.toString());
   
    // Create the entry to post to the collection
View Full Code Here

            int pathIndex = workspaceURL.indexOf( request.getServletPath() );
            if ( -1 != pathIndex ) {
                workspaceURL = workspaceURL.substring( 0, pathIndex ) + "/";
            }

            Service service = abderaFactory.newService();
            //service.setText("service");

            Workspace workspace = abderaFactory.newWorkspace();
            if ( title != null ) {
                workspace.setTitle(title);
            } else {
                workspace.setTitle("workspace");
            }
            workspace.setBaseUri( new IRI( workspaceURL ));

            Collection collection = workspace.addCollection("collection", href );
            Feed feed = getFeed( request );
            if ( feed != null ) {
                String title = feed.getTitle();
                if ( title != null ) {
                    collection.setTitle(title);
                } else {
                    collection.setTitle("entries");
                }
                collection.addAccepts("application/atom+xml;type=feed");
                collection.addAccepts("application/json;type=feed");
                collection.addAccepts("application/atom+xml;type=entry");
                collection.addAccepts("application/json;type=entry");
                List<Category> categories = feed.getCategories();
                if ( categories != null ) {
                    collection.addCategories(categories, false, null);
                } else {
                    collection.addCategories().setFixed(false);
                }

            } else {
                collection.setTitle("entries");
                // collection.addAccepts("application/atom+xml;type=feed");
                collection.addAccepts("application/atom+xml; type=entry");
                collection.addAccepts("application/json;type=entry");
                collection.addCategories().setFixed(false);           
            }
            workspace.addCollection(collection);
            service.addWorkspace(workspace);

            //FIXME add prettyPrint support
            try {
                service.getDocument().writeTo(response.getOutputStream());
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }

        } else if (path == null || path.length() == 0 || path.equals("/")) {
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Service

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.