Package org.infoset.xml

Examples of org.infoset.xml.Document


      return doc;
   }
   public static Document createMediaEntryDocument(String title,UUID id,Date created,String authorName,String href,MediaType type)
      throws XMLException
   {
      Document entryDoc = createEntryDocument(title,id,created,authorName);
      Element top = entryDoc.getDocumentElement();
      Element link = top.addElement(LINK_NAME);
      link.setAttributeValue("rel","edit-media");
      link.setAttributeValue("href",href);
      Element content = top.addElement(CONTENT_NAME);
      content.setAttributeValue("src",href);
View Full Code Here


   {
      if (!XMLRepresentationParser.isXML(entity.getMediaType())) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
      Document doc = null;
     
      try {
         DocumentDestination dest = new DocumentDestination();
         postParser.parse(entity,dest);
         doc = dest.getDocument();
      } catch (Exception ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("XML parse error: "+ex.getMessage());
      }
     
      if (facet!=null && facet.equals(ROLE_FACET)) {
        
      } else {
        
      }
     
      try {
         User user = fetch();
         if (user!=null) {
            Element top = doc.getDocumentElement();
            if (facet!=null && facet.equals(ROLE_FACET)) {
               if (top.getName().equals(XML.ROLE_NAME)) {
                  String sid = top.getAttributeValue("id");
                  String name = top.getAttributeValue("name");
                  Role role = null;
View Full Code Here

   public boolean feedUpdated(String path,UUID feedId,Date updated)
      throws IOException
   {
      File feedFile = makeFeedReference(path);
      try {
         Document doc = loader.load(feedFile.toURI());
         Feed feed = new Feed(doc);
         feed.setUpdated(updated);
         Writer out = new OutputStreamWriter(new FileOutputStream(feedFile),"UTF-8");
         XMLWriter.writeDocument(doc, out);
         out.close();
View Full Code Here

   public String getFeedTitle(String path,UUID id)
      throws IOException
   {
      File feedFile = makeFeedReference(path);
      try {
         Document doc = loader.load(feedFile.toURI());
         Feed feed = new Feed(doc);
         return feed.getTitle();
      } catch (XMLException ex) {
         throw new IOException("XML exception while getting title: "+ex.getMessage());
      }
View Full Code Here

      File feedFile = new File(dir,".feed.atom");
      org.atomojo.app.db.Feed feed = null;
      if (feedFile.exists()) {
        
         // exists, so we'll import it
         Document doc = loader.load(feedFile.toURI());
         Feed feedObj = new Feed(doc);
         String idS = feedObj.getId();
         if (!idS.startsWith("urn:uuid:")) {
            throw new IOException("Bad feed id: "+idS);
         }
         try {
            UUID id = UUID.fromString(idS.substring(9));
            feed = parent.createChild(dir.getName(), id);
         } catch (IllegalArgumentException ex) {
            throw new IOException(ex.getMessage());
         }
      } else {
        
         // create new feed
         feed = parent.createChild(dir.getName());
        
         // create feed document
         Document doc = AtomResource.createFeedDocument(dir.getName(),feed.getUUID(),feed.getCreated());
         Writer out = new OutputStreamWriter(new FileOutputStream(feedFile),"UTF-8");
         XMLWriter.writeDocument(doc, out);
         out.close();
      }
     
View Full Code Here

   }
  
   protected void importEntry(final org.atomojo.app.db.Feed parent,File file)
      throws SQLException,IOException,XMLException
   {
      Document doc = loader.load(file.toURI());
      org.atomojo.app.client.Entry entryObj = new org.atomojo.app.client.Entry(doc);
      String idS = entryObj.getId();
      if (!idS.startsWith("urn:uuid:")) {
         throw new IOException("Bad entry id: "+idS);
      }
View Full Code Here

     
      // create entry media
      entry.createResource(name, type);
     
      // creae entry document
      Document doc = AtomResource.createMediaEntryDocument(name,entry.getUUID(),entry.getCreated(),null,name,type);
      Writer out = new OutputStreamWriter(new FileOutputStream(new File(file.getParentFile(),"."+entry.getUUID()+".atom")),"UTF-8");
      XMLWriter.writeDocument(doc, out);
      out.close();
     
      // feed was edited
View Full Code Here

         request.getCookies().add(cookie);
      }
      Response response = client.handle(request);
      if (response.getStatus().isSuccess() && response.isEntityAvailable()) {
         XMLRepresentationParser parser = new XMLRepresentationParser();
         Document doc = parser.load(response.getEntity());
         this.entry = new Entry(doc);
      }
      if (response.isEntityAvailable()) {
         response.getEntity().release();
      }
View Full Code Here

      boolean hasEntity = false;
      try {
         hasEntity = response.isEntityAvailable();
         if (status.isSuccess() && hasEntity) {
            XMLRepresentationParser parser = new XMLRepresentationParser();
            Document doc = parser.load(response.getEntity());
            this.entry = new Entry(doc);
         }
      } finally {
         if (hasEntity) {
            response.getEntity().release();
View Full Code Here

   {
      if (!XMLRepresentationParser.isXML(entity.getMediaType())) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
      Document doc = null;
      try {
         doc = parser.load(entity);
      } catch (Exception ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("XML parse error: "+ex.getMessage());
      }
     
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(NM_USER) && !top.getName().equals(NM_GROUP)) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Unknown document element: "+top.getName());
      }
View Full Code Here

TOP

Related Classes of org.infoset.xml.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.