Package org.infoset.xml

Examples of org.infoset.xml.Element


                     throws XMLException
                  {
                     switch (item.getType()) {
                        case ElementItem:
                           if (level==0) {
                              Element e = (Element)item;
                              e.setAttributeValue(Attribute.XML_BASE, feedBaseURI);
                           } else {
                              Element e = (Element)item;
                              e.setBaseURI(null);
                           }
                           level++;
                           break;
                        case ElementEndItem:
                           level--;
View Full Code Here


      throws XMLException
   {
      String [] parts = new String[2];
      Term.split(term,parts);
      try {
         Element termE = constructor.createElement(AtomResource.CATEGORY_NAME);
         if (!parts[0].equals("http://www.atomojo.org/O/keyword/")) {
            termE.setAttributeValue("scheme",parts[0]);
         }
         termE.setAttributeValue("term",URLDecoder.decode(parts[1],"UTF-8"));
         dest.send(termE);
         if (value!=null && !(value instanceof Nil)) {
            dest.send(constructor.createCharacters(value.toString()));
         }
View Full Code Here

      }
   }
   static void link(ItemConstructor constructor,ItemDestination dest,String rel,String href)
      throws XMLException
   {
      Element linkE = constructor.createElement(AtomResource.LINK_NAME);
      linkE.setAttributeValue("rel",rel);
      linkE.setAttributeValue("href",href);
      linkE.setAttributeValue("type","application/atom+xml");
      dest.send(linkE);
     
      dest.send(constructor.createElementEnd(AtomResource.LINK_NAME));
   }
View Full Code Here

   public static void toXML(User user,ItemDestination dest)
      throws XMLException
   {
      ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
      dest.send(constructor.createDocument());
      Element userE = constructor.createElement(NM_USER);
      userE.setAttributeValue("alias",user.getAlias());
      userE.setAttributeValue("id",user.getId().toString());
      dest.send(userE);
      if (user.getName()!=null) {
         dest.send(constructor.createElement(NM_NAME));
         dest.send(constructor.createCharacters(user.getName()));
         dest.send(constructor.createElementEnd(NM_NAME));
View Full Code Here

      } 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());
      }

      if (facet!=null && !facet.equals(GROUPS_FACET)) {
         getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
         return new StringRepresentation("Unknown facet "+facet);
      }
     
      AuthService auth = (AuthService)getRequest().getAttributes().get(App.AUTH_SERVICE_ATTR);

      ChallengeResponse transCred = getRequest().getChallengeResponse();
      AuthCredentials cred = new AuthCredentials(transCred.getScheme().toString(),transCred.getIdentifier(),new String(transCred.getSecret()));
      if (facet==null) {

         if (!top.getName().equals(NM_USER)) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("Document element "+top.getName()+" not allowed on user.");
         }
        
         String password = top.getAttributeValue("password");
         if (password!=null) {
            password = password.trim();
         }

         Element nameE = top.getFirstElementNamed(NM_NAME);
         String name = null;
         if (nameE!=null) {
            name = nameE.getText();
         }
         Element emailE = top.getFirstElementNamed(NM_EMAIL);
         String email = null;
         if (emailE!=null) {
            email = emailE.getText();
         }
         try {

            User user = auth.getUser(cred,alias);
            if (user!=null) {
View Full Code Here

            try {
               Document doc = parser.load(response.getEntity());
               String session = doc.getDocumentElement().getAttributeValue("id");
               String id = doc.getDocumentElement().getAttributeValue("user-id");
               String alias = doc.getDocumentElement().getAttributeValue("user-alias");
               Element nameE = doc.getDocumentElement().getFirstElementNamed(NAME);
               Element emailE = doc.getDocumentElement().getFirstElementNamed(EMAIL);
               Identity identity = new Identity(session,id,alias,nameE==null ? null : nameE.getText(),emailE==null ? null : emailE.getText());
               context.getLogger().info("Authenticated "+username);
               actor.authenticated(form,identity);
            } catch (Exception ex) {
               context.getLogger().log(Level.SEVERE,"Cannot parse auth result.",ex);
               actor.unauthorized();
View Full Code Here

                           errorCount++;
                           return;
                        }
                        log.info("Entry: "+entryId);
                        String src = null;
                        Element content = entryDoc.getDocumentElement().getFirstElementNamed(AtomResource.CONTENT_NAME);
                        URI baseURI = null;
                        MediaType contentType = null;
                        if (content!=null) {
                           src = content.getAttributeValue("src");
                           String type = content.getAttributeValue("type");
                           if (type!=null) {
                              contentType = MediaType.valueOf(type);
                           }
                           baseURI = content.getBaseURI();
                        }
                        if (entries!=null) {
                           entries.add(entryId);
                        }
                        Entry entry = null;
View Full Code Here

         DocumentLoader loader = new SAXDocumentLoader();
         try {
            Document doc =loader.load(dbConf.toURI());
            Iterator<Element> databases = doc.getDocumentElement().getElementsByName(AdminXML.NM_DATABASE);
            while (databases.hasNext()) {
               Element databaseE = databases.next();
               URI href = databaseE.getBaseURI().resolve(databaseE.getAttributeValue("href"));
               if (!href.getScheme().equals("file")) {
                  throw new ConfigurationException("The scheme '"+href.getScheme()+"' is not support for database uri "+href);
               }
               DB db = new DB(log,new File(href.getSchemeSpecificPart()));
               Properties properties = db.getConfiguration();
               properties.setProperty("base-uri", databaseE.getBaseURI().toString());
               for (Attribute att : databaseE.getAttributes().values()) {
                  properties.put(att.getName().toString(),att.getText());
               }
               dbList.put(db.getName(),db);
            }
         } catch (IOException ex) {
View Full Code Here

   public static void writeList(File dir, Map<String,DB> dbList)
      throws IOException,XMLException
   {
      File dbConf = new File(dir,"db.conf");
      Document doc = InfosetFactory.getDefaultInfoset().createItemConstructor().createDocument();
      Element top = doc.createDocumentElement(AdminXML.NM_DATABASES);
      top.addCharacters("\n");
      for (DB db : dbList.values()) {
         Element database = top.addElement(AdminXML.NM_DATABASE);
         File compDir = new File(dir,db.getName());
         if (compDir.getCanonicalPath().equals(db.getDatabaseDir().getCanonicalPath())) {
            db.getDatabaseDir();
            database.setAttributeValue("href",db.getName());
         } else {
            database.setAttributeValue("href",db.getDatabaseDir().toURI().toString());
         }
         top.addCharacters("\n");
      }

      FileWriter writer = new FileWriter(dbConf);
View Full Code Here

      throws SQLException,IOException,XMLException
   {
      Iterator<Feed> feeds = getFeeds();
      ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
      dest.send(constructor.createDocument());
      Element service = constructor.createElement(XML.SERVICE);
      service.addNamespaceBinding(Name.NO_PREFIX,AtomResource.APP_NAMESPACE);
      service.addNamespaceBinding("atom",AtomResource.ATOM_NAMESPACE);
      if (xmlBase!=null) {
         service.setBaseURI(URI.create(xmlBase));
         service.setAttributeValue(Attribute.XML_BASE, xmlBase);
      }
      dest.send(service);
      dest.send(constructor.createElement(XML.WORKSPACE));
      dest.send(constructor.createElement(AtomResource.TITLE_NAME));
      dest.send(constructor.createCharacters("Feeds"));
      dest.send(constructor.createElementEnd(AtomResource.TITLE_NAME));
      while (feeds.hasNext()) {
         Feed feed = feeds.next();
         String href = locator.makeHref(feed);
         String title = storage.getFeedTitle(feed.getPath(),feed.getUUID());
         Element collection = constructor.createElement(XML.COLLECTION);
         collection.setAttributeValue("href",basePath+href);
         dest.send(collection);
         dest.send(constructor.createElement(AtomResource.TITLE_NAME));
         if (title!=null) {
            dest.send(constructor.createCharacters(title));
         }
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.