Package org.apache.abdera.writer

Examples of org.apache.abdera.writer.WriterOptions


      HttpServletResponse response)
        throws ServletException, IOException {

        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentType("application/atomsvc+xml; charset=utf-8");
        WriterOptions options = service.getDefaultWriterOptions();
        options.setCharset("UTF-8");
        service.writeTo(response.getOutputStream(),options);
    }
View Full Code Here


      int t = getTargetType(request);
      switch(t) {
        case COLLECTION:
          response.setStatus(HttpServletResponse.SC_OK);
          response.setContentType("application/atom+xml; charset=utf-8");
          WriterOptions options = feed.getDefaultWriterOptions();
          options.setCharset("UTF-8");
          feed.writeTo(response.getOutputStream(),options);
          break;
        case ENTRY:
          try {
            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;
          }
View Full Code Here

              entry.addLink(entry.getId().toString(), "self");
              feed.getRoot().insertEntry(entry);
              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();
            String media = read(request.getInputStream());
            Entry entry = getFactory().newEntry();
            String newID = AppTest.INSTANCE.getBase() + "/collections/entries/" + n;
            String slug = request.getHeader("Slug");
            entry.setId(newID);
            entry.setTitle(slug);
            entry.setUpdated(new Date());
            entry.setSummary(slug);
            entry.addLink(entry.getId().toString(), "edit");
            entry.addLink(AppTest.INSTANCE.getBase() + "/collections/media/" + n, "edit-media").setMimeType("text/plain");
            entry.addLink(entry.getId().toString(), "self");
            entry.setContent(new IRI(AppTest.INSTANCE.getBase() + "/collections/media/" + n), "text/plain");
            feed.getRoot().insertEntry(entry);
            this.media.put(entry.getId().toString(), media);
            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

TOP

Related Classes of org.apache.abdera.writer.WriterOptions

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.