Package org.apache.abdera.model

Examples of org.apache.abdera.model.Service


   */
  @Test
  public void testCollectionAcceptsMultipart() throws Exception {
      Abdera abdera = new Abdera();
      Factory factory = abdera.getFactory();
      Service svc = factory.newService();
      Workspace ws = svc.addWorkspace("test-ws");
      FOMMultipartCollection coll = (FOMMultipartCollection) ws.addMultipartCollection("test multipart coll", "/test-coll");  
      coll.setAcceptsEntry();
      coll.addAccepts("image/*", "multipart-related");           
     
      assertTrue("Collection does not accept entries.", coll.acceptsEntry());
      assertTrue("Collection does not accept multipart related images", coll.acceptsMultipart("image/*"));
     
      StringWriter sw = new StringWriter();
      svc.writeTo(sw);     
     
      String s = sw.toString();
      assertTrue("Service document does not specify acceptance of entries.", s.contains("application/atom+xml; type=entry"));
      assertTrue("Service document does not specify acceptance of apples.", s.contains("image/*"));
  }
View Full Code Here


      assertEquals(200, res.getStatus());
      assertEquals(ResponseType.SUCCESS, res.getType());
      assertTrue(MimeTypeHelper.isMatch(res.getContentType().toString(), Constants.APP_MEDIA_TYPE));

      Document<Service> doc = res.getDocument();
      Service service = doc.getRoot();
      assertEquals(1, service.getWorkspaces().size());

      Workspace workspace = service.getWorkspaces().get(0);
      assertEquals(1, workspace.getCollections().size());

      // Keep the loop in case we add other collections to the test.

      for (Collection collection : workspace.getCollections()) {
View Full Code Here

    ClientResponse resp = client.get("http://localhost:9002/");
    assertNotNull(resp);
    assertEquals(resp.getType(), ResponseType.SUCCESS);
    assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.APP_MEDIA_TYPE));
    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");
View Full Code Here

    super(10);
  }
 
  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

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

public class Features {

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

    new UsernamePasswordCredentials(
      "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);
   
View Full Code Here

    new UsernamePasswordCredentials(
      "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.
View Full Code Here

        Factory factory = abdera.getFactory();

        // 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");
View Full Code Here

    new UsernamePasswordCredentials(
      "username", "password"));
   
    // Get the service document and look up the collection uri
    Document<Service> service_doc = client.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 = client.post(uri, entry);
   
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.