Package org.infoset.xml

Examples of org.infoset.xml.Document


   {
      if (loadEntries) {
         Iterator<Element> entries = doc.getDocumentElement().getElementsByName(XML.ENTRY_NAME);
         ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
         while (entries.hasNext()) {
            Document entryDoc = constructor.createDocument(doc.getBaseURI());
            entryDoc.add((Child)entries.next().copyOfItem(true));
            add(new Entry(entryDoc));
         }
      }
   }
View Full Code Here


      XMLRepresentationParser parser = new XMLRepresentationParser();
      try {
         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_BACKUP));
         Document doc = dest.getDocument();
        
         Element top = doc.getDocumentElement();
         String location = top.getAttributeValue("location");
         if (location==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is missing.");
         }
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();
         parser.parse(entity,dest);
         doc = dest.getDocument();
      } catch (Exception ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("XML parse error: "+ex.getMessage());
      }
     
      try {
         User user = fetch();
         if (user!=null) {
            Element top = doc.getDocumentElement();
            String alias = top.getAttributeValue("alias");
            Element name = top.getFirstElementNamed(XML.NAME_NAME);
            Element email = top.getFirstElementNamed(XML.EMAIL_NAME);
            if (alias!=null && !User.isAlias(alias)) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
View Full Code Here

         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      XMLRepresentationParser parser = new XMLRepresentationParser();
      Document doc = null;
     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_APP));
         doc = dest.getDocument();
         RemoteApp app = new RemoteApp(db,doc.getDocumentElement());
         if (app.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
            return new StringRepresentation("Remote app with name "+app.getName()+" already exists.");
         }
         if (app.create()) {
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");
      if (value!=null) {
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();
         parser.parse(entity,dest);
         doc = dest.getDocument();
         Element top = doc.getDocumentElement();
         String sid = top.getAttributeValue("id");
         UUID id = sid==null ? UUID.randomUUID() : UUID.fromString(sid);
         String alias = top.getAttributeValue("alias");

         try {
View Full Code Here

         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
     
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      XMLRepresentationParser parser = new XMLRepresentationParser();
      Document doc = null;
     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_TARGET));
         doc = dest.getDocument();
         SyncTarget target = new SyncTarget(db,doc.getDocumentElement());
         if (target.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
            return new StringRepresentation("Target with name "+target.getName()+" already exists.");
         }
         if (target.create()) {
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());
      }
      XMLRepresentationParser parser = new XMLRepresentationParser();
      Document doc = null;
     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_TARGET));
         doc = dest.getDocument();
         SyncTarget target = new SyncTarget(db,doc.getDocumentElement());
         String lname = target.getName();
         if (!lname.equals(name)) {
            getResponse().setStatus(Status.CLIENT_ERROR_EXPECTATION_FAILED);
            return new StringRepresentation("Cannot change the name of the target.");
         }
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();
         parser.parse(entity,dest);
         doc = dest.getDocument();
         Element top = doc.getDocumentElement();
         String sid = top.getAttributeValue("id");
         UUID id = sid==null ? UUID.randomUUID() : UUID.fromString(sid);
         String alias = top.getAttributeValue("alias");
         String password = top.getAttributeValue("password");
         Element name = top.getFirstElementNamed(XML.NAME_NAME);
View Full Code Here

         // Get author name for identity
         String authorName = user.getName();

         // Create entry document
         Document doc = null;
         try {
            String title = URLDecoder.decode(slug,"UTF-8");
            doc = AtomResource.createMediaEntryDocument(title,entry.getUUID(),entry.getCreated(),authorName,file,mediaType);
         } catch (XMLException ex) {
            try {
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.