Package org.apache.abdera.model

Examples of org.apache.abdera.model.Document


      String uri,
      Base base,
      RequestOptions options) {
    if (options == null) options = getDefaultRequestOptions();
    if (base instanceof Document) {
      Document d = (Document) base;
      if (options.getSlug() == null &&
          d.getSlug() != null)
        options.setSlug(d.getSlug());
     
      if (options.isConditionalPut()) {
        if (d.getEntityTag() != null)
          options.setIfMatch(d.getEntityTag());
        else if (d.getLastModified() != null)
          options.setIfUnmodifiedSince(d.getLastModified());
      }
    }
    return execute("PUT", uri, new BaseRequestEntity(base, options.isUseChunked()), options);
  }
View Full Code Here


   
    ClientResponse resp = client.get(url);
    switch(resp.getType()) {
      case SUCCESS:
        try {
          Document doc = resp.getDocument();
          response.setContentType("application/json");
          response.setCharacterEncoding("UTF-8");
          if (doc.getEntityTag() != null)
            response.setHeader("ETag", doc.getEntityTag().toString());
          if (doc.getLanguage() != null)
            response.setHeader("Content-Language", doc.getLanguage());
          if (doc.getLastModified() != null)
            response.setDateHeader("Last-Modified", doc.getLastModified().getTime());
          OutputStream out = response.getOutputStream();
          doc.writeTo("json",out);
        } catch (Exception e) {
          response.sendError(500);
          return;
        }
      case CLIENT_ERROR:
View Full Code Here

   * is a bit of a last resort approach
   */
  @SuppressWarnings("unchecked")
  public static <T extends Element>Direction guessDirectionFromEncoding(T element, boolean ignoredir) {
    if (!ignoredir && hasDirection(element)) return getDirection(element);
    Document doc = element.getDocument();
    if (doc == null) return Direction.UNSPECIFIED;
    return Bidi.guessDirectionFromEncoding(doc.getCharset());
  }
View Full Code Here

      log.debug(Localizer.get("RETURNING.DOCUMENT"));
      BaseResponseContext response = new BaseResponseContext(base);
      response.setStatus(status);
      if (lastModified != null) response.setLastModified(lastModified);
      response.setContentType(MimeTypeHelper.getMimeType(base));
      Document doc = base instanceof Document ? (Document)base : ((Element)base).getDocument();
      if (doc.getEntityTag() != null) {
        response.setEntityTag(doc.getEntityTag());
      } else if (doc.getLastModified() != null) {
        response.setLastModified(doc.getLastModified());
      }
      return response;
  }
View Full Code Here

    Encryption enc = absec.getEncryption();
    EncryptionOptions options = enc.getDefaultEncryptionOptions();
    options.setDataEncryptionKey(key);
   
    // Encrypt the document using the generated key
    Document enc_doc = enc.encrypt(entry.getDocument(), options);
   
    assertEquals(
      enc_doc.getRoot().getQName(),
      new QName(
        "http://www.w3.org/2001/04/xmlenc#",
        "EncryptedData"));
   
    // Decrypt the document using the generated key
View Full Code Here

    Encryption enc = absec.getEncryption();
    EncryptionOptions options = enc.getDefaultEncryptionOptions();
    options.setDataEncryptionKey(key);
   
    // Encrypt the document using the generated key
    Document enc_doc = enc.encrypt(entry.getDocument(), options);

    enc_doc.writeTo(System.out);
   
    System.out.println("\n\n");
   
    // Decrypt the document using the generated key
    Document<Entry> entry_doc = enc.decrypt(enc_doc, options);
View Full Code Here

    // Prepare the encryption options
    Encryption enc = absec.getEncryption();
   
    // Encrypt the document using A's DHContext
    EncryptionOptions options = context_a.getEncryptionOptions(enc);
    Document enc_doc = enc.encrypt(entry.getDocument(), options);

    enc_doc.writeTo(System.out);
   
    System.out.println("\n\n");
   
    // Decrypt the document using B's DHContext
    options = context_b.getEncryptionOptions(enc);
View Full Code Here

  protected void setUp() throws Exception {
    baseURI = new URI("http://www.feedparser.org/tests/wellformed/atom10/");
  }

  public void testAtom10Namespace() throws Exception {
    Document doc = parse(baseURI.resolve("atom10_namespace.xml"));
    assertNotNull(doc);
  }
View Full Code Here

    Document doc = parse(baseURI.resolve("atom10_namespace.xml"));
    assertNotNull(doc);
  }
 
  public void testEntryAuthorEmail() throws Exception {
    Document doc = parse(baseURI.resolve("entry_author_email.xml"));
    Feed feed = (Feed) doc.getRoot();
    Entry entry = feed.getEntries().get(0);
    Person person = entry.getAuthor();
    assertEquals(person.getEmail(), "me@example.com");
  }
View Full Code Here

    Person person = entry.getAuthor();
    assertEquals(person.getEmail(), "me@example.com");
  }
 
  public void testEntryAuthorName() throws Exception {
    Document doc = parse(baseURI.resolve("entry_author_name.xml"));
    Feed feed = (Feed) doc.getRoot();
    Entry entry = feed.getEntries().get(0);
    Person person = entry.getAuthor();
    assertEquals(person.getName(), "Example author");   
  }
View Full Code Here

TOP

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

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.