Package org.apache.abdera.model

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


                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


    // Sign the entry
    entry = sig.sign(entry, options);     
   
    // 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();
   
    System.out.println("Valid? " + sig.verify(entry,null));
View Full Code Here

        entry.setContent(new IRI("http://example.org/xml"), "text/xml");

        Writer json = abdera.getWriterFactory().getWriter("json");
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        entry.writeTo(json, outputStream);
        String output = outputStream.toString();
        assertTrue(output.contains("\"type\":\"text/xml\""));
        assertTrue(output.contains("\"src\":\"http://example.org/xml\""));
        assertTrue(output.contains("\"content\":"));
    }
View Full Code Here

        assertEquals("CN=James M Snell, OU=WebAhead, O=IBM, L=Hanford, ST=California, C=US", certs[0].getSubjectDN()
            .getName());

        // 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) {
                    }
View Full Code Here

        // Sign the entry
        entry = sig.sign(entry, options);

        // 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();

        System.out.println("Valid? " + sig.verify(entry, null));
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: { "id":"urn:uuid:97893C35372BE77BD51200273434152", "title":"test", "content":{
         * "attributes":{"type":"html"}, "children":[{ "name":"b", "attributes":{}, "children":["foo"]}]},
         * "authors":[{"name":"James"}], "categories":[{"term":"term"}] }
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.