protected void setEntryContent(Factory factory, Entry e, String content) { Content ct = factory.newContent(Content.Type.XML); ct.setValue(content); e.setContentElement(ct); }
public Type getContentType() { Content content = getContentElement(); return (content != null) ? content.getContentType() : null; }
public String getContent() { Content content = getContentElement(); return (content != null) ? content.getValue() : null; }
/** * Sets the content for this entry * * @throws MimeTypeParseException */ public Content setContent(String value, String mediatype) { try { FOMFactory factory = (FOMFactory)this.factory; Content content = factory.newContent(new MimeType(mediatype)); content.setValue(value); content.setMimeType(mediatype); setContentElement(content); return content; } catch (javax.activation.MimeTypeParseException e) { throw new org.apache.abdera.util.MimeTypeParseException(e); } }
if (content != null) final IRI src = content.getSrc(); if (src != null) Type contentType = content.getContentType(); org.xcmis.spi.utils.MimeType mediaType; if (contentType == Type.XML || contentType == Type.XHTML || contentType == Type.HTML break; case XML : mediaType = convertMimeType(content.getMimeType()); break; default : data = Base64.decodeBase64(content.getText().getBytes()); data = content.getValue().getBytes(charset == null ? "UTF-8" : charset); new BaseContentStream(content.getDataHandler().getInputStream(), null, convertMimeType(content .getMimeType()));
Content.Type contenttype = content.getContentType(); if (contenttype.equals(Content.Type.TEXT) && !needToWriteLanguageFields(content)) { jstream.writeQuoted(content.getValue()); } else { jstream.startObject(); jstream.writeField("attributes"); jstream.startObject(); switch (content.getContentType()) { case TEXT: case HTML: case MEDIA: case XML: jstream.writeField("type", content.getMimeType()); jstream.writeField("xml:base", element.getResolvedBaseUri()); writeLanguageFields(content, jstream); jstream.writeField("src", content.getResolvedSrc()); jstream.endObject(); jstream.writeField("children"); switch (content.getContentType()) { case TEXT: jstream.startArray(); jstream.writeQuoted(content.getValue()); jstream.endArray(); break; case HTML: Div div = HtmlHelper.parse(content.getValue()); writeElementValue(div, jstream);
content.setContentType(Content.Type.XML); content.setValue(value);
return false; } else { if ((content.getSrc() != null || content.getContentType() == Content.Type.MEDIA) && entry .getSummaryElement() == null) { log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", false));
public IRI getContentSrc() { Content content = getContentElement(); return (content != null) ? content.getResolvedSrc() : null; }
public MimeType getContentMimeType() { Content content = getContentElement(); return (content != null) ? content.getMimeType() : null; }
content.setContentType(null); content.setSrc(contentLink); entry.setContentElement(content);
public InputStream getContentStream() throws IOException { Content content = getContentElement(); DataHandler dh = content.getDataHandler(); return dh.getInputStream(); }
if ((entry.getContentElement() == null) || (entry.getContentElement().getValueElement() == null)) { throw new IllegalArgumentException("Entry does not contain a valid content element"); Element element = entry.getContentElement().getValueElement(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {
/** * Sets the content for this entry * * @throws MimeTypeParseException * @throws IRISyntaxException */ public Content setContent(IRI uri, String mediatype) { try { FOMFactory factory = (FOMFactory)this.factory; Content content = factory.newContent(new MimeType(mediatype)); content.setSrc(uri.toString()); setContentElement(content); return content; } catch (javax.activation.MimeTypeParseException e) { throw new org.apache.abdera.util.MimeTypeParseException(e); } }
if (content != null && content.getResolvedSrc() != null) sig.addDocument(content.getResolvedSrc().toASCIIString());
/** * Sets the content for this entry */ public Content setContent(String value, Content.Type type) { FOMFactory factory = (FOMFactory)this.factory; Content content = factory.newContent(type); content.setValue(value); setContentElement(content); return content; }
@POST @Path("/books/feed/relative") @Consumes("application/atom+xml") public Response addBookAsEntryRelativeURI(Entry e) throws Exception { try { String text = e.getContentElement().getValue(); StringReader reader = new StringReader(text); JAXBContext jc = JAXBContext.newInstance(Book.class); Book b = (Book)jc.createUnmarshaller().unmarshal(reader); books.put(b.getId(), b); URI uri = URI.create("books/entries/" + Long.toString(b.getId())); return Response.created(uri).entity(e).build(); } catch (Exception ex) { return Response.serverError().build(); } }
protected OMElement _create(OMElement src) { OMElement el = null; FOMFactory fomfactory = (FOMFactory)factory; Object obj = null; if (src instanceof Content) obj = ((Content)src).getContentType(); if (src instanceof Text) obj = ((Text)src).getTextType(); el = fomfactory.createElement(src.getQName(), (OMContainer)fomfactory.newDocument(), factory, obj); return el; }
protected void setEntryContent(Factory factory, Entry e, String content) { Content ct = factory.newContent(Content.Type.XML); ct.setValue(content); e.setContentElement(ct); }
@POST @Path("/books/feed") @Consumes("application/atom+xml") public Response addBookAsEntry(Entry e) { try { String text = e.getContentElement().getValue(); StringReader reader = new StringReader(text); JAXBContext jc = JAXBContext.newInstance(Book.class); Book b = (Book)jc.createUnmarshaller().unmarshal(reader); books.put(b.getId(), b); URI uri = uField.getBaseUriBuilder().path("books").path("entries") .path(Long.toString(b.getId())).build(); return Response.created(uri).entity(e).build(); } catch (Exception ex) { return Response.serverError().build(); } }