Package org.apache.abdera.factory

Examples of org.apache.abdera.factory.Factory


      @GET
      @Path("feed")
      @Produces(MediaType.APPLICATION_ATOM_XML)
      public Feed getFeed(@Context UriInfo uri) throws Exception
      {
         Factory factory = abdera.getFactory();
         Assert.assertNotNull(factory);
         Feed feed = abdera.getFactory().newFeed();
         feed.setId("tag:example.org,2007:/foo");
         feed.setTitle("Test Feed");
         feed.setSubtitle("Feed subtitle");
View Full Code Here


    assertNotNull(cert);
   
    // Create the entry to sign
    Abdera abdera = new Abdera();
    AbderaSecurity absec = new AbderaSecurity(abdera);
    Factory factory = abdera.getFactory();
   
    Entry entry = factory.newEntry();
    entry.setId("http://example.org/foo/entry")
    entry.setUpdated(new java.util.Date());
    entry.setTitle("This is an entry");
    entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
    entry.addAuthor("James");
View Full Code Here

    assertNotNull(cert);
   
    // Create the entry to sign
    Abdera abdera = new Abdera();
    AbderaSecurity absec = new AbderaSecurity(abdera);
    Factory factory = abdera.getFactory();
   
    Entry entry = factory.newEntry();
    entry.setId("http://example.org/foo/entry")
    entry.setUpdated(new java.util.Date());
    entry.setTitle("This is an entry");
    entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
    entry.addAuthor("James");
View Full Code Here

        AtomDate.valueOf(when).getValue());
  }
 
 
  public static Total addTotal(Entry entry, int total) {
    Factory factory = entry.getFactory();
    Total totalelement =
      (Total)factory.newExtensionElement(
        ThreadConstants.THRTOTAL, entry);
    totalelement.setValue(total);
    return totalelement;
  }
View Full Code Here

    SecretKey key = keyGenerator.generateKey();

    // Create the entry to encrypt
    Abdera abdera = new Abdera();
    AbderaSecurity absec = new AbderaSecurity(abdera);
    Factory factory = abdera.getFactory();
   
    Entry entry = factory.newEntry();
    entry.setId("http://example.org/foo/entry");
    entry.setUpdated(new java.util.Date());
    entry.setTitle("This is an entry");
    entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
    entry.addAuthor("James");
View Full Code Here

        if (isFeed && isCollection) {
            reportError("Atom feed can only be created from a collection wrapper", null);
        } else if (!isFeed && isCollection) {
            reportError("Atom entry can only be created from a single object", null);
        }
        Factory factory = Abdera.getNewFactory();
       
        Element atomElement = null;
        try {
            if (isFeed && !isCollection) {
                atomElement = createFeedFromCollectionWrapper(factory, o, cls);
View Full Code Here

    assertEquals(URIHelper.normalize(s1), "http://www.example.org/foo/-/foo");
    assertEquals(URIHelper.normalize(s2), "http://www.example.org:81/foo/-/foo");
  }
 
  public void testFactory() throws Exception {
    Factory factory = getFactory();
    Person author = factory.newAuthor();
    assertNotNull(author);
    author = factory.newAuthor();
    author.setName("a");
    author.setEmail("b");
    author.setUri("c");
    assertNotNull(author);
    assertEquals(author.getName(),"a");
    assertEquals(author.getEmail(), "b");
    assertEquals(author.getUri().toString(), "c");
    author = factory.newAuthor();
    author.setName("a");
    author.setEmail("b");
    author.setUri("c");
    assertNotNull(author);
    assertEquals(author.getName(),"a");
    assertEquals(author.getEmail(), "b");
    assertEquals(author.getUri().toString(), "c");
    Category category = factory.newCategory();
    assertNotNull(category);
    category = factory.newCategory();
    category.setScheme("a");
    category.setTerm("b");
    category.setLabel("c");
    assertNotNull(category);
    assertEquals(category.getScheme().toString(), "a");
    assertEquals(category.getTerm(), "b");
    assertEquals(category.getLabel(), "c");
    Collection collection = factory.newCollection();
    assertNotNull(collection);
    Content content = factory.newContent(Content.Type.TEXT);
    assertNotNull(content);
    assertEquals(content.getContentType(), Content.Type.TEXT);
    content = factory.newContent(Content.Type.HTML);
    assertEquals(content.getContentType(), Content.Type.HTML);
    content = factory.newContent(Content.Type.XHTML);
    assertEquals(content.getContentType(), Content.Type.XHTML);
    content = factory.newContent(Content.Type.MEDIA);
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    content = factory.newContent(Content.Type.XML);
    assertEquals(content.getContentType(), Content.Type.XML);
    content = factory.newContent(new MimeType("text/foo"));
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    assertEquals(content.getMimeType().toString(), "text/foo");
    Person contributor = factory.newContributor();
    assertNotNull(contributor);
    contributor = factory.newContributor();
    contributor.setName("a");
    contributor.setEmail("b");
    contributor.setUri("c");
    assertNotNull(contributor);
    assertEquals(contributor.getName(),"a");
    assertEquals(contributor.getEmail(), "b");
    assertEquals(contributor.getUri().toString(), "c");
    contributor = factory.newContributor();
    contributor.setName("a");
    contributor.setEmail("b");
    contributor.setUri("c");
    assertNotNull(contributor);
    assertEquals(contributor.getName(),"a");
    assertEquals(contributor.getEmail(), "b");
    assertEquals(contributor.getUri().toString(), "c");
    Control control = factory.newControl();
    assertNotNull(control);
    control = factory.newControl();
    control.setDraft(true);
    assertTrue(control.isDraft());
    Date now = new Date();
    DateTime dateTime = factory.newDateTime(Constants.UPDATED, null);
    dateTime.setValue(AtomDate.valueOf(now));
    assertEquals(dateTime.getDate(), now);
    Calendar cal = Calendar.getInstance();
    dateTime = factory.newDateTime(Constants.UPDATED, null);
    dateTime.setCalendar(cal);
    assertEquals(dateTime.getCalendar(), cal);
    dateTime = factory.newDateTime(Constants.UPDATED, null);
    dateTime.setDate(now);
    assertEquals(dateTime.getDate(), now);
    dateTime = factory.newDateTime(Constants.UPDATED, null);
    assertNotNull(dateTime);
    dateTime = factory.newDateTime(Constants.UPDATED, null);
    dateTime.setTime(now.getTime());
    assertEquals(dateTime.getTime(), now.getTime());
    dateTime = factory.newDateTime(Constants.UPDATED, null);
    dateTime.setString(AtomDate.format(now));
    assertEquals(dateTime.getString(), AtomDate.format(now));
    assertEquals(dateTime.getDate(), now);
    Generator generator = factory.newDefaultGenerator();
    assertNotNull(generator);
    assertEquals(generator.getText(), Version.APP_NAME);
    assertEquals(generator.getVersion(), Version.VERSION);
    assertEquals(generator.getUri().toString(), Version.URI);
    Div div = factory.newDiv();
    assertNotNull(div);
    Document doc = factory.newDocument();
    assertNotNull(doc);
    Element el = factory.newEmail();
    assertNotNull(el);
    el = factory.newEmail();
    el.setText("a");
    assertEquals(el.getText(), "a");
    Entry entry = factory.newEntry();
    assertNotNull(entry);
    entry = factory.newEntry();
    assertNotNull(entry);
    Element ee = factory.newExtensionElement(new QName("urn:foo", "bar", "b"));
    assertNotNull(ee);
    assertEquals(ee.getQName(), new QName("urn:foo", "bar", "b"));
    Feed feed = factory.newFeed();
    assertNotNull(feed);
    generator = factory.newGenerator();
    assertNotNull(generator);
    generator = factory.newGenerator();
    generator.setUri(Version.URI);
    generator.setVersion(Version.VERSION);
    generator.setText(Version.APP_NAME);
    assertNotNull(generator);
    assertEquals(generator.getText(), Version.APP_NAME);
    assertEquals(generator.getVersion(), Version.VERSION);
    assertEquals(generator.getUri().toString(), Version.URI);
    content = factory.newContent(Content.Type.HTML);
    content.setValue("a");
    assertNotNull(content);
    assertEquals(content.getValue(), "a");
    assertEquals(content.getContentType(), Content.Type.HTML);
    Text text = factory.newRights(Text.Type.HTML);
    text.setValue("a");
    assertNotNull(text);
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.HTML);
    text = factory.newSubtitle(Text.Type.HTML);
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.HTML);
    text = factory.newSummary(Text.Type.HTML);
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.HTML);
    text = factory.newText(Constants.TITLE,Text.Type.HTML, null);
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.HTML);
    assertEquals(text.getQName(), Constants.TITLE);
    text = factory.newTitle(Text.Type.HTML);
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.HTML);
    IRIElement iri = factory.newIcon();
    assertNotNull(iri);
    iri = factory.newIcon();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newIcon();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newID();
    assertNotNull(iri);
    iri = factory.newID();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newID();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newIRIElement(Constants.ID, null);
    assertNotNull(iri);
    iri = factory.newIRIElement(Constants.ID, null);
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newIRIElement(Constants.ID, null);
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    Link link = factory.newLink();
    assertNotNull(link);
    link = factory.newLink();
    link.setHref("http://example.org/foo");
    link.setRel("a");
    link.setMimeType("text/foo");
    link.setTitle("b");
    link.setHrefLang("en");
    link.setLength(10);
    assertEquals(link.getHref().toString(), "http://example.org/foo");
    assertEquals(link.getRel(), "a");
    assertEquals(link.getMimeType().toString(), "text/foo");
    assertEquals(link.getTitle(), "b");
    assertEquals(link.getHrefLang(), "en");
    assertEquals(link.getLength(), 10);
    link = factory.newLink();
    link.setHref("http://example.org/foo");
    link.setRel("a");
    link.setMimeType("text/foo");
    link.setTitle("b");
    link.setHrefLang("en");
    link.setLength(10);
    assertEquals(link.getHref().toString(), "http://example.org/foo");
    assertEquals(link.getRel(), "a");
    assertEquals(link.getMimeType().toString(), "text/foo");
    assertEquals(link.getTitle(), "b");
    assertEquals(link.getHrefLang(), "en");
    assertEquals(link.getLength(), 10);
    iri = factory.newLogo();
    assertNotNull(iri);
    iri = factory.newLogo();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newLogo();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    content = factory.newContent(new MimeType("text/foo"));
    content.setSrc("foo");
    assertNotNull(content);
    assertEquals(content.getMimeType().toString(), "text/foo");
    assertEquals(content.getSrc().toString(), "foo");
    content = factory.newContent(new MimeType("text/foo"));
    content.setDataHandler(new DataHandler(new ByteArrayDataSource("foo".getBytes())));
    assertEquals(content.getValue(), "Zm9v");
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    el = factory.newName();
    assertNotNull(el);
    el = factory.newName();
    el.setText("a");
    assertEquals(el.getText(), "a");
    Parser parser = factory.newParser();
    assertNotNull(parser);
    Person person = factory.newPerson(Constants.AUTHOR, null);
    assertNotNull(person);
    assertEquals(person.getQName(), Constants.AUTHOR);
    person = factory.newPerson(Constants.AUTHOR, null);
    person.setName("a");
    person.setEmail("b");
    person.setUri("c");
    assertEquals(person.getName(),"a");
    assertEquals(person.getEmail(), "b");
    assertEquals(person.getUri().toString(), "c");
    person = factory.newPerson(Constants.AUTHOR, null);
    person.setName("a");
    person.setEmail("b");
    person.setUri("c");
    assertEquals(person.getName(),"a");
    assertEquals(person.getEmail(), "b");
    assertEquals(person.getUri().toString(), "c");
    now = new Date();
    dateTime = factory.newPublished();
    dateTime.setValue(AtomDate.valueOf(now));
    assertEquals(dateTime.getDate(), now);
    cal = Calendar.getInstance();
    dateTime = factory.newPublished();
    dateTime.setCalendar(cal);
    assertEquals(dateTime.getCalendar(), cal);
    dateTime = factory.newPublished();
    dateTime.setDate(now);
    assertEquals(dateTime.getDate(), now);
    dateTime = factory.newPublished();
    assertNotNull(dateTime);
    dateTime = factory.newPublished();
    dateTime.setTime(now.getTime());
    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);
    assertEquals(el.getQName(), Constants.NAME);
    el = factory.newElement(Constants.NAME);
    el.setText("a");
    assertNotNull(el);
    assertEquals(el.getQName(), Constants.NAME);
    assertEquals(el.getText(), "a");
    text = factory.newText(Constants.TITLE, Text.Type.TEXT);
    assertNotNull(text);
    assertEquals(text.getTextType(), Text.Type.TEXT);
    text = factory.newRights();
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.TEXT);
    text = factory.newSubtitle();
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.TEXT);
    text = factory.newSummary();
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.TEXT);
    text = factory.newText(Constants.TITLE, Text.Type.TEXT,null);
    text.setValue("a");
    assertEquals(text.getQName(), Constants.TITLE);
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.TEXT);
    text = factory.newTitle();
    text.setValue("a");
    assertEquals(text.getValue(), "a");
    assertEquals(text.getTextType(), Text.Type.TEXT);
    content = factory.newContent(Content.Type.TEXT);
    content.setValue("a");
    assertEquals(content.getValue(), "a");
    assertEquals(content.getContentType(), Content.Type.TEXT);
    now = new Date();
    dateTime = factory.newUpdated();
    dateTime.setValue(AtomDate.valueOf(now));
    assertEquals(dateTime.getDate(), now);
    cal = Calendar.getInstance();
    dateTime = factory.newUpdated();
    dateTime.setCalendar(cal);
    assertEquals(dateTime.getCalendar(), cal);
    dateTime = factory.newUpdated();
    dateTime.setDate(now);
    assertEquals(dateTime.getDate(), now);
    dateTime = factory.newUpdated();
    assertNotNull(dateTime);
    dateTime = factory.newUpdated();
    dateTime.setTime(now.getTime());
    assertEquals(dateTime.getTime(), now.getTime());
    dateTime = factory.newUpdated();
    dateTime.setString(AtomDate.format(now));
    assertEquals(dateTime.getString(), AtomDate.format(now));
    assertEquals(dateTime.getDate(), now);
    iri = factory.newUri();
    assertNotNull(iri);
    iri = factory.newUri();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    iri = factory.newUri();
    iri.setValue("http://example.org/foo");
    assertEquals(iri.getValue().toString(), "http://example.org/foo");
    Workspace workspace = factory.newWorkspace();
    assertNotNull(workspace);
    div = factory.newDiv();
    content = factory.newContent(Content.Type.XHTML);
    content.setValueElement(div);
    assertNotNull(content);
    assertEquals(content.getContentType(), Content.Type.XHTML);
    assertNotNull(content.getValueElement());
    assertEquals(content.getValueElement(), div);
    content = factory.newContent(new MimeType("application/xml"));
    content.setValueElement(div);
    assertNotNull(content);
    assertEquals(content.getContentType(), Content.Type.XML);
    assertNotNull(content.getValueElement());
    assertEquals(content.getValueElement(), div);
    text = factory.newRights();
    text.setValueElement(div);
    assertNotNull(text);
    assertEquals(text.getTextType(), Text.Type.XHTML);
    assertEquals(text.getValueElement(), div);
    text = factory.newSubtitle();
    text.setValueElement(div);
    assertNotNull(text);
    assertEquals(text.getTextType(), Text.Type.XHTML);
    assertEquals(text.getValueElement(), div);
    text = factory.newSummary();
    text.setValueElement(div);
    assertNotNull(text);
    assertEquals(text.getTextType(), Text.Type.XHTML);
    assertEquals(text.getValueElement(), div);
    text = factory.newText(Constants.TITLE, null);
    text.setValueElement(div);
    assertNotNull(text);
    assertEquals(text.getQName(), Constants.TITLE);
    assertEquals(text.getTextType(), Text.Type.XHTML);
    assertEquals(text.getValueElement(), div);
    text = factory.newTitle();
    text.setValueElement(div);
    assertNotNull(text);
    assertEquals(text.getTextType(), Text.Type.XHTML);
    assertEquals(text.getValueElement(), div);
  }
View Full Code Here

public class ThreadTest extends TestCase {

  public static void testThread() throws Exception {
   
    Abdera abdera = new Abdera();
    Factory factory = abdera.getFactory();
    Entry e1 = factory.newEntry();
    Entry e2 = factory.newEntry();
   
    e1.setId("tag:example.org,2006:first");
    e2.setId("tag:example.org,2006:second");
   
    ThreadHelper.addInReplyTo(e2,e1); // e2 is a response to e1
View Full Code Here

public class MediaTest extends TestCase {

  public static void testMedia() throws Exception {
   
    Abdera abdera = new Abdera();
    Factory factory = abdera.getFactory();
    Entry entry = factory.newEntry();
    MediaGroup group = entry.addExtension(GROUP);
    MediaContent content = group.addExtension(CONTENT);
    content.setUrl("http://example.org");
    content.setBitrate(123);
    content.setChannels(2);
View Full Code Here

                                       @PathParam("assetName") String assetName) {
        try {
            //Throws RulesRepositoryException if the package or asset does not exist
            AssetItem asset = repository.loadPackage(packageName).loadAsset(assetName);
           
            Factory factory = Abdera.getNewFactory();
            Feed f = factory.getAbdera().newFeed();
            f.setTitle("Version history of " + asset.getName());

            UriBuilder base;           
            if (asset.isHistoricalVersion()) {
                base = uriInfo.getBaseUriBuilder().path("packages").path(asset.getPackageName()).path("assets").path("versions").path(Long.toString(asset.getVersionNumber()));
            } else {
                base = uriInfo.getBaseUriBuilder().path("packages").path(asset.getPackageName()).path("assets").path(asset.getName()).path("versions");
            }
            f.setBaseUri(base.build().toString());
                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                    AssetItem historicalAsset = it.next();
                    if (historicalAsset.getVersionNumber() != 0) {
                        Entry e = factory.getAbdera().newEntry();
                        e.setTitle(Long.toString(historicalAsset
                                .getVersionNumber()));
                        e.setUpdated(historicalAsset.getLastModified().getTime());
                        Link l = factory.newLink();
                        l.setHref(uriInfo
                                .getBaseUriBuilder()
                                .path("packages")
                                .path(asset.getPackageName())
                                .path("assets")
View Full Code Here

TOP

Related Classes of org.apache.abdera.factory.Factory

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.