Package org.apache.abdera.model

Examples of org.apache.abdera.model.Entry.writeTo()


    }
   
    private Entry addEntry(String endpointAddress) throws Exception {
        Entry e = createBookEntry(256, "AtomBook");
        StringWriter w = new StringWriter();
        e.writeTo(w);
       
        PostMethod post = new PostMethod(endpointAddress);
        post.setRequestEntity(
             new StringRequestEntity(w.toString(), "application/atom+xml", null));
        HttpClient httpclient = new HttpClient();
View Full Code Here


          Entry entry = (Entry)request.getDocument().getRoot().clone();
          String key = request.getTarget().getParameter("entry");
          setEditDetail(request,entry,key);
          File file = getFile(key, false);
          FileOutputStream out = new FileOutputStream(file);
          entry.writeTo(out);
          String edit = entry.getEditLinkResolvedHref().toString();
          return ProviderHelper.returnBase(entry.getDocument(), 200, null).setLocation(edit);
        } catch (Exception e) {
          return ProviderHelper.badrequest(request);
        }
View Full Code Here

    assertEquals(certs.length, 1);
    assertEquals(certs[0].getSubjectDN().getName(), "CN=James M Snell, OU=WebAhead, O=IBM, L=Hanford, ST=California, C=US");
   
    // Check the round trip
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    entry.writeTo(out); // do not use the pretty writer, it will break the signature
    ByteArrayInputStream bais = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> entry_doc = abdera.getParser().parse(bais);
    entry = entry_doc.getRoot();
    assertTrue(sig.verify(entry, null))// the signature better still be valid
   
View Full Code Here

            Entry entry = feed.getRoot().getEntries().get(getTarget());
            response.setStatus(HttpServletResponse.SC_OK);
            response.setContentType("application/atom+xml; charset=utf-8");
            options = entry.getDefaultWriterOptions();
            options.setCharset("UTF-8");
            entry.writeTo(response.getOutputStream(),options);
          } catch (Exception e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            break;
          }
          break;
View Full Code Here

              response.setStatus(HttpServletResponse.SC_CREATED);
              response.setHeader("Location", entry.getId().toString());
              response.setHeader("Content-Location", entry.getId().toString());
              WriterOptions woptions = entry.getDefaultWriterOptions();
              woptions.setCharset("UTF-8");
              entry.writeTo(response.getOutputStream(),woptions);
              return;
            }
          }
          if (MimeTypeHelper.isMatch(request.getContentType(), "text/plain")) {
            int n = feed.getRoot().getEntries().size();
View Full Code Here

            response.setStatus(HttpServletResponse.SC_CREATED);
            response.setHeader("Location", entry.getId().toString());
            response.setHeader("Content-Location", entry.getId().toString());
            WriterOptions woptions = entry.getDefaultWriterOptions();
            woptions.setCharset("UTF-8");
            entry.writeTo(response.getOutputStream(),woptions);
            return;
          }
          response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        } catch (Exception e) {}
        break;
View Full Code Here

          Entry entry = (Entry)request.getDocument().getRoot().clone();
          String key = createKey(request);
          setEditDetail(request,entry,key);
          File file = getFile(key);
          FileOutputStream out = new FileOutputStream(file);
          entry.writeTo(out);
          String edit = entry.getEditLinkResolvedHref().toString();
          return ProviderHelper.returnBase(entry.getDocument(), 201, null).setLocation(edit);
        } catch (Exception e) {
          return ProviderHelper.badrequest(request);
        }
View Full Code Here

    MediaTitle title = content.addExtension(TITLE);
    title.setType(Type.PLAIN);
    title.setText("This is a sample");
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    entry.writeTo(out);
   
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Parser parser = abdera.getParser();
    Document<Entry> doc = parser.parse(in);
    entry = doc.getRoot();
View Full Code Here

    entry.newId();
    entry.setTitle("test");
    entry.setContentAsHtml("<b>foo</b>");
    entry.addAuthor("James");
    entry.addCategory("term");
    entry.writeTo("json", System.out);
   
    /**
     * Produces:
     *
     * {
 
View Full Code Here

   
    // once the object has been serialized, we can see that it's a parseable Atom document
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> doc = abdera.getParser().parse(in);
    Entry entry = doc.getRoot();
    entry.writeTo(System.out);
   
    System.out.println();
   
    // demonstrate serialization using an annotated java object
    // annotations allow the developer to customize the way the
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.