Package org.restlet.ext.atom

Examples of org.restlet.ext.atom.Feed


public class ConverterTestCase extends RestletTestCase {

    public void testObjectToRepresentation() {
        ConverterService cs = new ConverterService();
        Feed feed = new Feed();
        Representation representation = cs.toRepresentation(feed);
        assertEquals(MediaType.APPLICATION_ATOM, representation.getMediaType());
    }
View Full Code Here


        assertEquals("AtomPub Test Site", atomService.getWorkspaces().get(0)
                .getTitle());
        assertEquals("entry", atomService.getWorkspaces().get(0)
                .getCollections().get(0).getTitle());

        final Feed atomFeed = atomService.getWorkspaces().get(0)
                .getCollections().get(0).getFeed();

        // Write the feed into a file.
        final File feedFile = new File(testDir, "feed.xml");
        atomFeed.write(new BufferedOutputStream(new FileOutputStream(feedFile)));

        // Get the service from the file
        final FileRepresentation fileRepresentation = new FileRepresentation(
                feedFile, MediaType.TEXT_XML);
        final Feed atomFeed2 = new Feed(fileRepresentation);

        assertEquals(atomFeed2.getAuthors().get(0).getName(), atomFeed
                .getAuthors().get(0).getName());
        assertEquals(atomFeed2.getEntries().get(0).getContent()
                .getInlineContent().getText(), atomFeed2.getEntries().get(0)
                .getContent().getInlineContent().getText());
        assertEquals(atomFeed2.getEntries().get(0).getTitle().getContent(),
                atomFeed2.getEntries().get(0).getTitle().getContent());

        BioUtils.delete(testDir, true);
    }
View Full Code Here

                        MediaType.APPLICATION_ATOM);
                Representation rep = resource.post(r);
                EntryContentHandler<?> entryContentHandler = new EntryContentHandler<Object>(
                        entity.getClass(), (Metadata) getMetadata(),
                        getLogger());
                Feed feed = new Feed();
                feed.getEntries().add(new Entry(rep, entryContentHandler));
            } catch (ResourceException re) {
                throw new ResourceException(re.getStatus(),
                        "Can't add entity to this entity set "
                                + resource.getReference());
            } finally {
View Full Code Here

                // Guess the type of query based on the URI structure
                switch (guessType(targetUri)) {
                case TYPE_ENTITY_SET:
                    FeedContentHandler<T> feedContentHandler = new FeedContentHandler<T>(
                            entityClass, entityType, metadata, getLogger());
                    setFeed(new Feed(result, feedContentHandler));
                    this.count = feedContentHandler.getCount();
                    this.entities = feedContentHandler.getEntities();
                    break;
                case TYPE_ENTITY:
                    EntryContentHandler<T> entryContentHandler = new EntryContentHandler<T>(
                            entityClass, entityType, metadata, getLogger());
                    Feed feed = new Feed();
                    feed.getEntries().add(
                            new Entry(result, entryContentHandler));
                    setFeed(feed);
                    entities = new ArrayList<T>();
                    if (entryContentHandler.getEntity() != null) {
                        entities.add(entryContentHandler.getEntity());
                    }
                    break;
                case TYPE_UNKNOWN:
                    // Guess the type of query based on the returned
                    // representation
                    Representation rep = new StringRepresentation(result
                            .getText());
                    String string = rep.getText().substring(0,
                            Math.min(100, rep.getText().length()));
                    if (string.contains("<feed")) {
                        feedContentHandler = new FeedContentHandler<T>(
                                entityClass, entityType, metadata, getLogger());
                        setFeed(new Feed(rep, feedContentHandler));
                        this.count = feedContentHandler.getCount();
                        this.entities = feedContentHandler.getEntities();
                    } else if (string.contains("<entry")) {
                        entryContentHandler = new EntryContentHandler<T>(
                                entityClass, entityType, metadata, getLogger());
                        feed = new Feed();
                        feed.getEntries().add(
                                new Entry(rep, entryContentHandler));
                        setFeed(feed);
                        entities = new ArrayList<T>();
                        if (entryContentHandler.getEntity() != null) {
                            entities.add(entryContentHandler.getEntity());
View Full Code Here

            Attributes attrs) throws SAXException {
        if (State.ASSOCIATION == getState()) {
            // Delegates to the inline content handler
            if (uri.equalsIgnoreCase(Feed.ATOM_NAMESPACE)) {
                if (localName.equals("feed")) {
                    Feed feed = new Feed();
                    String attr = attrs.getValue("xml:base");
                    if (attr != null) {
                        feed.setBaseReference(new Reference(attr));
                    }
                    inlineFeed = feed;
                    this.inlineFeedHandler.startFeed(feed);
                } else if (localName.equals("link")) {
                    Link link = new Link();
View Full Code Here

    private Representation representAtom()
        throws ResourceException
    {
        try
        {
            Feed feed = new Feed();
            feed.setTitle( new Text( MediaType.TEXT_PLAIN, "All entities" ) );
            List<Entry> entries = feed.getEntries();
            final Iterable<EntityReference> query = entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.<String, Object>emptyMap() );
            for( EntityReference entityReference : query )
            {
                Entry entry = new Entry();
                entry.setTitle( new Text( MediaType.TEXT_PLAIN, entityReference.toString() ) );
View Full Code Here

    this.baseUrl = baseUrl;
    this.title = title;
  }

  public Feed getFeed(String repository, int count) {
    Feed feed = getConfiguredFeed();
    List<SearchResult> results = app.getRecentArtifacts(repository, 1, count);
    for (SearchResult result : results) {
      Entry entry = toEntry(result);
      feed.getEntries().add(entry);
    }
    feed.setUpdated(new Date());
    return feed;
  }
View Full Code Here

    feed.setUpdated(new Date());
    return feed;
  }

  private Feed getConfiguredFeed() {
    Feed feed = new Feed();
    feed.setGenerator(getGenerator());
    feed.setTitle(new Text(MediaType.TEXT_PLAIN, title));
    return feed;
  }
View Full Code Here

TOP

Related Classes of org.restlet.ext.atom.Feed

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.