Package org.infoset.xml

Examples of org.infoset.xml.Element


     
      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);
         Element email = top.getFirstElementNamed(XML.EMAIL_NAME);
         if (alias!=null && !User.isAlias(alias)) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The alias '"+alias+"' is not a valid alias.");
         }

         try {
            User user = db.createUser(id,alias,name==null ? null : name.getText(),email==null ? null : email.getText());
            if (user!=null) {
               if (password!=null) {
                  user.setPassword(password);
               }
               Representation responseEntity = new DBObjectRepresentation(MediaType.APPLICATION_XML,user);
View Full Code Here


               break;
            case 1:
               switch (item.getType()) {
                  case ElementItem:
                  {
                     Element e = (Element)item;
                     Name name = ((Named)item).getName();
                     if (name.equals(COLLECTION) || name.equals(OLD_COLLECTION)) {
                        if (!startedWorkspace) {
                           listener.onStartWorkspace("");
                           startedWorkspace = true;
                        }
                        String href = e.getAttributeValue("href");
                        if (href==null) {
                           return;
                        }
                        title = null;
                        URI base = e.getBaseURI();
                        if (base==null) {
                           base = ulocation;
                        }
                        collectionLocation = base.resolve(href);
                        //Logger.getAnonymousLogger().info("Resolved '"+href+"' against '"+base+"' to get '"+collectionLocation+"'");
View Full Code Here

   }
  
   public void generate(ItemConstructor constructor,ItemDestination dest,boolean contents)
      throws XMLException
   {
      Element top = constructor.createElement(XML.GROUP_NAME);
      top.setAttributeValue("id",uuid.toString());
      top.setAttributeValue("alias",name);
      top.setAttributeValue("realm",realm.getUUID().toString());
      dest.send(top);
      if (contents) {
         dest.send(constructor.createCharacters("\n"));
         dest.send(constructor.createElement(XML.ROLES_NAME));
         boolean first = true;
View Full Code Here

  
   public void updateFeed(Feed feed,Document doc)
      throws AppException
   {
      // Check to make sure the document is an entry
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(AtomResource.FEED_NAME)) {
         throw new AppException(Status.CLIENT_ERROR_BAD_REQUEST,"Document element is not a feed: "+top.getName());
      }

      try {
         feed.edited();
      } catch (SQLException ex) {
View Full Code Here

   public Entry createEntry(User user,Feed feed,Document entryDoc)
      throws AppException
   {
     
      // Check for non-entry document elements
      Element top = entryDoc.getDocumentElement();
      if (!top.getName().equals(AtomResource.ENTRY_NAME)) {
         throw new AppException(Status.CLIENT_ERROR_BAD_REQUEST,"Only entries can be posted to feeds with the Atom mime type.  Found: "+top.getName());
      }

      EntryIndex index = AtomResource.indexEntry(log,top);

      if (index.getId()!=null) {
View Full Code Here

   public Entry updateEntry(User user,Feed feed, Entry entry,Document doc)
      throws AppException
   {
     
      // Check to make sure the document is an entry
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(AtomResource.ENTRY_NAME)) {
         throw new AppException(Status.CLIENT_ERROR_BAD_REQUEST,"Document element is not an entry: "+top.getName());
      }

      // Set the modification time
      Date modified = null;
     
View Full Code Here

         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_RESTORE));
         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.");
         }
         location = location.trim();
         if (location.length()==0) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is empty.");
         }
         File dir = new File(location);
         if (!dir.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The "+dir.getAbsolutePath()+" doesn't exist.");
         }
         if (!dir.canRead()) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("Cannot write to "+dir.getAbsolutePath());
         }

         Set<String> dbNames = new TreeSet<String>();
         Iterator<Element> names = top.getElementsByName(AdminXML.NM_NAME);
         while (names.hasNext()) {
            dbNames.add(names.next().getText());
         }
        
         List<Map<String,DBInfo>> lists = new ArrayList<Map<String,DBInfo>>();
View Full Code Here

   }
  
   public void generate(ItemConstructor constructor,ItemDestination dest)
      throws XMLException
   {
      Element top = constructor.createElement(XML.USER_NAME);
      top.setAttributeValue("id",user.getUUID().toString());
      String avalue = getAlias();
      // The alias shouldn't be null unless there is database corruption.
      if (avalue!=null) {
         top.setAttributeValue("alias",avalue);
      }
      dest.send(top);
      if (getName()!=null) {
         dest.send(constructor.createElement(XML.NAME_NAME));
         dest.send(constructor.createCharacters(getName()));
View Full Code Here

         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_RESTORE));
         Document doc = dest.getDocument();
        
         Element top = doc.getDocumentElement();
         String location = top.getAttributeValue("location");
         if (location!=null) {
            location = location.trim();
            if (location.length()==0) {
               location = null;
            }
         }
         Element appE = top.getFirstElementNamed(AdminXML.NM_APP);
         if (location==null && appE==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("A location or remote app is required.");
         }

         RemoteApp app = null;
         if (location==null) {
            app = new RemoteApp(db,appE);
            app.unmarshall();
            if (!app.getIntrospection().isAbsolute()) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("URI could not be resolved to absolute URI: "+appE.getAttributeValue("introspect"));
            }
         } else {
            File dir = new File(location);
            if (!dir.exists()) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
View Full Code Here

      boolean idDone = false;
      boolean createdDone = false;
      boolean modifiedDone = false;
      boolean editedDone = false;
      List<Child> toRemove = new ArrayList<Child>();
      Element linkEdit = null;
      Element linkEditMedia = null;
      Element content = null;
      Element author = null;
      for (Child c : entry) {
         if (c instanceof Element) {
            Element e = (Element)c;
            if (e.getName().equals(ID_NAME)) {
               idDone = true;
               e.clear();
               e.addCharacters("urn:uuid:"+id.toString());
            } else if (e.getName().equals(PUBLISHED_NAME) && created!=null) {
               createdDone = true;
               /*
               e.clear();
               e.addCharacters(toXSDDate(created));
                */
            } else if (e.getName().equals(UPDATED_NAME)) {
               modifiedDone = true;
            } else if (e.getName().equals(EDITED_NAME)) {
               editedDone = true;
               e.clear();
               e.setPrefix("app");
               e.addCharacters(toXSDDate(modified));
            } else if (e.getName().equals(AUTHOR_NAME)) {
               author = e;
            } else if (e.getName().equals(LINK_NAME)) {
               String rel = e.getAttributeValue("rel");
               if ("edit".equals(rel)) {
                  linkEdit = e;
               } else if ("self".equals(rel)) {
                  toRemove.add(e);
               } else if ("edit-media".equals(rel)) {
                  if (media!=null) {
                     linkEditMedia = e;
                  } else {
                     toRemove.add(e);
                  }
               }
            } else if (e.getName().equals(CONTENT_NAME)) {
               content = e;
            }
         }
      }
      if (!modifiedDone) {
         entry.addElement(0,UPDATED_NAME).addCharacters(toXSDDate(modified));
      }
      if (!editedDone) {
         Element e = entry.addElement(0,EDITED_NAME);
         e.addCharacters(toXSDDate(modified));
         e.setPrefix("app");
      }
      if (!createdDone && created!=null) {
         entry.addElement(0,PUBLISHED_NAME).addCharacters(toXSDDate(created));
      }
      if (!idDone) {
View Full Code Here

TOP

Related Classes of org.infoset.xml.Element

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.