Package org.infoset.xml

Examples of org.infoset.xml.Document


         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,username,password));
         Response response = client.handle(request);
         if (response.getStatus().isSuccess()) {
            XMLRepresentationParser parser = new XMLRepresentationParser();
            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);
View Full Code Here


                  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

      Map<String,DB> dbList = new HashMap<String,DB>();
      File dbConf = new File(dir,"db.conf");
      if (dbConf.exists()) {
         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);
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())) {
View Full Code Here

   protected void copy(Feed source,Feed parent,String name)
   {
      XMLRepresentationParser parser = new XMLRepresentationParser();
      try {
         // get the feed document without the entries
         Document feedDoc = parser.load(app.getStorage().getFeedHead(source.getPath(), source.getUUID()));

         // Create the feed.  The ID will be changed since the feed exits
         Feed newFeed = app.createFeed(parent.getPath()+name, feedDoc);
        
         // copy the entries
         Iterator<Entry> entries = source.getEntries();
         while (entries.hasNext()) {
            Entry entry = entries.next();
            Document entryDoc = parser.load(app.getEntryRepresentation("", entry));
            Iterator<EntryMedia> mediaResources = entry.getResources();
            if (mediaResources.hasNext()) {
               // we have a media entry and so copy the media
               EntryMedia media = mediaResources.next();
               Representation mediaRep = app.getStorage().getMedia(source.getPath(), source.getUUID(), media.getName());
View Full Code Here

  
   public static Identity createIdentity(Representation entity)
      throws IOException,XMLException
   {
      XMLRepresentationParser parser = new XMLRepresentationParser();
      Document doc = parser.load(entity);
      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(IdentityFilter.NAME);
      Element emailE = doc.getDocumentElement().getFirstElementNamed(IdentityFilter.EMAIL);
      Identity identity = new Identity(session,id,alias,nameE==null ? null : nameE.getText(),emailE==null ? null : emailE.getText());
      Iterator<Element> roles = doc.getDocumentElement().getElementsByName(IdentityFilter.ROLE);
      while (roles.hasNext()) {
         Element role = roles.next();
         UUID rid = UUID.fromString(role.getAttributeValue("id"));
         String name = role.getAttributeValue("name");
         if (identity.roles==null) {
            identity.roles = new TreeMap<UUID,String>();
         }
         identity.roles.put(rid,name);
      }
      Iterator<Element> groups = doc.getDocumentElement().getElementsByName(IdentityFilter.GROUP);
      while (groups.hasNext()) {
         Element group = groups.next();
         UUID gid = UUID.fromString(group.getAttributeValue("id"));
         String galias = group.getAttributeValue("alias");
         if (identity.groups==null) {
View Full Code Here

         String charset = postType.getParameters().getValues("charset");
         if (charset==null) {
            charset = "UTF-8";
         }
         // Should be an entry
         Document doc = null;
         if (entity instanceof InfosetRepresentation) {
            doc = ((InfosetRepresentation)entity).getDocument();
         } else {
            DocumentLoader loader = new SAXDocumentLoader();
            try {
View Full Code Here

         charset = "UTF-8";
      }
      try {
         DocumentLoader loader = new SAXDocumentLoader();
         Reader r = new InputStreamReader(entity.getStream(),charset);
         Document doc = loader.load(r);
         r.close();
        
         try {
            app.updateFeed(feed,doc);
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
View Full Code Here

            if (charset==null) {
               charset = "UTF-8";
            }
            try {
               Reader r = new InputStreamReader(request.getEntity().getStream(),charset);
               Document doc = loader.load(r);
               r.close();

               Name top = doc.getDocumentElement().getName();
               if (top.equals(AtomResource.FEED_NAME)) {
                  String requestPath = request.getResourceRef().getRemainingPart();
                  if (requestPath==null) {
                     requestPath = "";
                  }
View Full Code Here

         String path = request.getResourceRef().getPath();
         path = path.substring(0,path.length()-1);
         getLogger().info("Manipulating service document to adjust to path: "+path);
         try {
            XMLRepresentationParser parser = new XMLRepresentationParser();
            Document introspection = parser.load(appResponse.getEntity());
            Iterator<Element> workspaces = introspection.getDocumentElement().getElementsByName(WORKSPACE);
            while (workspaces.hasNext()) {
               Element workspace = workspaces.next();
               Iterator<Element> collections = workspace.getElementsByName(COLLECTION);
               while (collections.hasNext()) {
                  Element collection = collections.next();
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.