Package org.apache.abdera.model

Examples of org.apache.abdera.model.Collection


    public void testCollectionAccepts() throws Exception {
        Abdera abdera = new Abdera();
        Factory factory = abdera.getFactory();
        Service svc = factory.newService();
        Workspace ws = svc.addWorkspace("test-ws");
        Collection coll = ws.addCollection("test-coll", ws.getTitle() + "/test-coll");
        coll.setAcceptsEntry();
        assertTrue("Collection does not accept entries.", coll.acceptsEntry());
        coll.addAccepts("application/apples");
        assertTrue("Collection does not accept apples.", coll.accepts("application/apples"));
        StringWriter sw = new StringWriter();
        svc.writeTo(sw);
        // System.out.println(sw);
        String s = sw.toString();
        assertTrue("Service document does not specify acceptance of entries.", s.contains("application/atom+xml; type=entry"));
View Full Code Here


    Text text = getTitleElement();
    return (text != null) ? text.getTextType() : null;
  }

  public Collection getCollection() {
    Collection coll = getFirstChild(COLLECTION);
    if (coll == null) coll = getFirstChild(PRE_RFC_COLLECTION);
    return coll;
  }
View Full Code Here

    Document<Service> doc = resp.getDocument();
    Service service = doc.getRoot();
    assertEquals(service.getWorkspaces().size(), 1);
    Workspace workspace = service.getWorkspace("Abdera");
    assertEquals(workspace.getCollections().size(), 1);
    Collection collection = workspace.getCollection("title for any sample feed");
    assertNotNull(collection);
    assertTrue(collection.acceptsEntry());
    assertEquals(collection.getResolvedHref().toString(), "http://localhost:9002/sample");
    resp.release();
  }
View Full Code Here

        System.out.println(indent + "id=" + feed.getId());
        System.out.println(indent + "title=" + feed.getTitle());
        System.out.println(indent + "updated=" + feed.getUpdated());
        System.out.println(indent + "author=" + feed.getAuthor());
        System.out.println(indent + "self link=" + feed.getSelfLink());
        Collection collection = feed.getCollection();
        if (collection == null) {
            System.out.println(indent + "collection=null");
        } else {
            System.out.println(indent + "collection=" + collection);
        }
View Full Code Here

  private Document<Service> init_service_doc(Abdera abdera) {
    Factory factory = abdera.getFactory();
    Service service = factory.newService();
    Workspace workspace = service.addWorkspace("Simple");
    try {
      Collection collection = workspace.addCollection("Simple", "atom/feed");
      collection.setAccept("entry");
      collection.addCategories().setFixed(false);
    } catch (Exception e) {}
    return service.getDocument();
  }
View Full Code Here

    Document<Service> introspection =
      abderaClient.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
    Entry entry = factory.newEntry();
    entry.setId("tag:example.org,2006:foo");
    entry.setTitle("This is the title");
    entry.setUpdated(new Date());
    entry.addAuthor("James");
    entry.setContent("This is the content");
    report("The Entry to Post", entry.toString());
   
    // Post the entry. Be sure to grab the resolved HREF of the collection
    Document<Entry> doc = abderaClient.post(
      collection.getResolvedHref().toString(),
      entry).getDocument();
   
    // In some implementations (such as Google's GData API, the entry URI is
    // distinct from it's edit URI.  To be safe, we should assume it may be
    // different
View Full Code Here

  public static void main(String... args) throws Exception {
   
    Abdera abdera = new Abdera();
    Service service = abdera.newService();
    Workspace workspace = service.addWorkspace("My workspace");
    Collection collection = workspace.addCollection("My collection", "foo");
   
    // Specify which features are supported by the collection
    FeaturesHelper.addFeature(collection, FeaturesHelper.FEATURE_DRAFTS);
    FeaturesHelper.addFeature(collection, FeaturesHelper.FEATURE_TEXT_TITLE, Feature.Status.REQUIRED);
    FeaturesHelper.addFeature(collection, FeaturesHelper.FEATURE_SLUG, Feature.Status.UNSUPPORTED);
View Full Code Here

      "username", "password"));
   
    // Get the service document and look up the collection uri
    Document<Service> service_doc = abderaClient.get(start).getDocument();
    Service service = service_doc.getRoot();
    Collection collection = service.getWorkspaces().get(0).getCollections().get(0);
    String uri = collection.getHref().toString();
     
    // Post the entry to the collection
    Response response = abderaClient.post(uri, entry);
   
    // Check the result
View Full Code Here

      "username", "password"));
   
    // Get the service doc and locate the href of the collection
    Document<Service> service_doc = abderaClient.get(start).getDocument();
    Service service = service_doc.getRoot();
    Collection collection = service.getWorkspaces().get(0).getCollections().get(1);
    String uri = collection.getHref().toString();
     
    // Set the filename.  Note: the Title header was used by older drafts
    // of the Atom Publishing Protocol and should no longer be used.  The
    // current Roller APP implementation still currently requires it.
    RequestOptions options = abderaClient.getDefaultRequestOptions();
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 = abderaClient.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
        Entry entry = factory.newEntry();
        entry.setId("tag:example.org,2006:foo");
        entry.setTitle("This is the title");
        entry.setUpdated(new Date());
        entry.addAuthor("James");
        entry.setContent("This is the content");
        report("The Entry to Post", entry.toString());

        // Post the entry. Be sure to grab the resolved HREF of the collection
        Document<Entry> doc = abderaClient.post(collection.getResolvedHref().toString(), entry).getDocument();

        // In some implementations (such as Google's GData API, the entry URI is
        // distinct from it's edit URI. To be safe, we should assume it may be
        // different
        IRI entryUri = doc.getBaseUri();
View Full Code Here

TOP

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

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.