Package org.apache.abdera.model

Examples of org.apache.abdera.model.Service


     */
  @Test
    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"));
        assertTrue("Service document does not specify acceptance of apples.", s.contains("application/apples"));
    }
View Full Code Here


    @Produces({ "application/atomsvc+xml", "application/xml", "text/xml",
                "application/atomsvc+json", "application/json" })
    public Response get() {

        User authenticatedUser = getAuthenticatedUser();
        Service service = abdera.newService();
        Workspace contactsWorkspace = service.addWorkspace("Contact List Feeds");
        synchronized (Database.users) {
            if (Database.ADMIN_USERNAME.equals(authenticatedUser.getUsername())) {
                for (User user : Database.users.values()) {
                    addContactList(contactsWorkspace, user);
                }
            } else {
                addContactList(contactsWorkspace, authenticatedUser);
            }
        }
        if (Database.ADMIN_USERNAME.equals(authenticatedUser.getUsername())) {
            Workspace adminWorkspace = service.addWorkspace("Administrative Feeds");
            Collection usersCollection = adminWorkspace.addCollection("User List", uriInfo.getBaseUri() + "users");
        }
        return Response.ok(service).build();
    }
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(), 2);
    Collection collection = workspace.getCollection("CouchDB Feed");
    assertNotNull(collection);
    assertTrue(collection.acceptsEntry());
    assertEquals(collection.getResolvedHref().toString(), "http://localhost:9002/couchdb");
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(), 2);
    Collection collection = workspace.getCollection("Filesystem Feed");
    assertNotNull(collection);
    assertTrue(collection.acceptsEntry());
    assertEquals(collection.getResolvedHref().toString(), "http://localhost:9002/fs");
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

            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

            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

   
                // getting Repository Info
                RequestOptions requestOptions = ecm.createRequestOptions();
                ClientResponse cResp = ecm.getRequest(urlRepositoryInfo, requestOptions);
                Document<Service> doc = cResp.getDocument();
                Service ecmInfo = doc.getRoot();
                JSONObject ecmInfoJSON = cfh.getRepositoryInfo(ecmInfo);

                // ADD: getting cmis:folder type

                // getting getTypes uri
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").setAcceptsEntry();
      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

  }
 
  public static void testSelectors() throws Exception {
   
    Abdera abdera = new Abdera();
    Service service = abdera.newService();
    Workspace workspace = service.addWorkspace("a");
    Collection collection1 = workspace.addCollection("a1","a1");
    collection1.setAcceptsEntry();
    FeaturesHelper.addFeature(collection1, FeaturesHelper.FEATURE_DRAFTS);
    Collection collection2 = workspace.addCollection("a2","a2");
    collection2.setAccept("image/*");
 
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.