Package org.infoset.xml

Examples of org.infoset.xml.DocumentLoader


   }
  
   public void load(URI location)
      throws IOException,XMLException
   {
      DocumentLoader loader = new SAXDocumentLoader();
      Document doc = loader.load(location);
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(SERVER)) {
         throw new XMLException("Expecting "+SERVER+" but found "+top.getName());
      }
     
View Full Code Here


   }

   public void load(URL url)
      throws IOException,XMLException
   {
      DocumentLoader loader = new SAXDocumentLoader();
      try {
         loader.generate(url.toURI(), new ItemDestination() {
            String separator = "/";
            TermNode current = null;
            public void send(Item item)
               throws XMLException
            {
View Full Code Here

      String charset = postType.getParameters().getValues("charset");
      if (charset==null) {
         charset = "UTF-8";
      }
      Document doc = null;
      DocumentLoader loader = new SAXDocumentLoader();
      try {
         Reader r = new InputStreamReader(entity.getStream(),charset);
         doc = loader.load(r);
         r.close();
      } catch (IOException ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("I/O error while parsing document: "+ex.getMessage());
      } catch (XMLException ex) {
View Full Code Here

                  }
                  link(constructor,dest,"related",resourceBase+feed.getPath());
                  dest.send(constructor.createElementEnd(AtomResource.ENTRY_NAME));
               }
            }
            DocumentLoader loader = new SAXDocumentLoader();
            Iterator<TermInstance<Entry>> entries = app.getDB().getEntriesByTerm(key.dbTerm,key.value);
            while (entries.hasNext()) {
               TermInstance<Entry> termValue = entries.next();
               Entry entry = termValue.getTarget();
               boolean ok = true;
               for (URI otherTerm : termSet.keySet()) {
                  TermQuery other = termSet.get(otherTerm);
                  ok = entry.hasTerm(other.dbTerm, other.value);
                  if (!ok) {
                     break;
                  }
               }
               if (ok) {
                  Feed feed = entry.getFeed();
                  String feedPath = feed.getPath();
                  String feedBaseURI = resourceBase.toString()+feedPath;
                  dest.send(constructor.createCharacters("\n"));

                  // get the entry representation
                  Representation rep = app.getStorage().getEntry(feedBaseURI,feedPath,feed.getUUID(),entry.getUUID());

                  // avoid thread creation because reading an output representation requires a thread
                  StringWriter sw = new StringWriter();
                  rep.write(sw);
                  rep.release();
                  loader.generate(new StringReader(sw.toString()), new RemoveDocumentFilter(dest));
               }
              
            }
         }
      } catch (Exception ex) {
View Full Code Here

   }
     
   public void load(URI location)
      throws IOException,XMLException
   {
      DocumentLoader loader = new SAXDocumentLoader();
      Document doc = loader.load(location);
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(AdminXML.NM_SERVER)) {
         throw new XMLException("Expecting "+AdminXML.NM_SERVER+" but found "+top.getName());
      }
      String value = top.getAttributeValue("autoconf-check");
View Full Code Here

         if (!inFile.canRead()) {
            getResponse().setStatus(Status.CLIENT_ERROR_EXPECTATION_FAILED);
            return new StringRepresentation("Cannot read input file "+inFile.getAbsolutePath());
         }
         getContext().getLogger().info("Restoring database from "+inFile.getAbsolutePath());
         DocumentLoader loader = new SAXDocumentLoader();
         loader.generate(inFile.toURI(),new RestoreDestination(getContext().getLogger(),db));
         getContext().getLogger().info("Restore finished.");
         getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
         return null;
      } catch (IOException ex) {
         getContext().getLogger().log(Level.SEVERE,"Cannot get write data to output.",ex);
View Full Code Here

      String charset = entity.getMediaType().getParameters().getValues("charset");
      if (charset==null) {
         charset = "UTF-8";
      }
      try {
         DocumentLoader loader = new SAXDocumentLoader();
         Reader r = new InputStreamReader(entity.getStream(),charset);
         Document doc = loader.load(r);
         r.close();
        
         // Find the entry
        
         try {
View Full Code Here

      super.loadSchema(name, connection, sqlLocation);
      if (name.equals("auth")) {
         URL defaultDB = this.getClass().getResource("default-db.xml");
         if (defaultDB!=null) {
            try {
               DocumentLoader loader = new SAXDocumentLoader();
               RestoreDestination restore = new RestoreDestination(LOG,this);
               loader.generate(defaultDB.toURI(), restore);
            } catch (XMLException ex) {
               throw new IOException(ex.getMessage());
            } catch (URISyntaxException ex) {
               throw new IOException(ex.getMessage());
            }
View Full Code Here

                  term(constructor,dest,fterm.getTerm().getURI(),fterm.getValue());
               }
               link(constructor,dest,"related",resourceBase+feed.getPath());
               dest.send(constructor.createElementEnd(AtomResource.ENTRY_NAME));
            }
            DocumentLoader loader = new SAXDocumentLoader();
            Iterator<TermInstance<Entry>> entries = app.getDB().getEntriesByTerm(dbTerm,value);
            while (entries.hasNext()) {
               TermInstance<Entry> termValue = entries.next();
               Entry entry = termValue.getTarget();
               Feed feed = entry.getFeed();
               String feedPath = feed.getPath();
               String feedBaseURI = resourceBase.toString()+feedPath;
               dest.send(constructor.createCharacters("\n"));

               // get the entry representation
               Representation rep = app.getStorage().getEntry(feedBaseURI,feedPath,feed.getUUID(),entry.getUUID());
              
               // avoid thread creation because reading an output representation requires a thread
               StringWriter sw = new StringWriter();
               rep.write(sw);
               rep.release();
               loader.generate(new StringReader(sw.toString()), new RemoveDocumentFilter(dest));
              
            }
         }
      } catch (Exception ex) {
         throw new XMLException("Exception while getting ancestors.",ex);
View Full Code Here

               if (progress.update) {
                  progress.status = appResponse.getStatus().getCode();
               } else {
                  try {
                     Reader r = appResponse.getEntity().getReader();
                     DocumentLoader loader = new SAXDocumentLoader();
                     Document entryDoc = loader.load(r);
                     Entry entry = new Entry(entryDoc);
                     entry.index();
                     progress.entryId = entry.getId();
                     progress.status = appResponse.getStatus().getCode();
                     getLogger().info("Entry: "+progress.entryId+", status="+progress.status);
View Full Code Here

TOP

Related Classes of org.infoset.xml.DocumentLoader

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.