Package org.infoset.xml

Examples of org.infoset.xml.Document


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


               if (href==null) {
                  continue;
               }
               URI location = child.getBaseURI().resolve(href);
               try {
                  Document included = docLoader.load(location);
                  Element top = included.getDocumentElement();
                  if (!top.getName().equals(CONTEXT)) {
                     continue;
                  }
                  loadContext(appContext,top);
               } 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(SERVER)) {
         throw new XMLException("Expecting "+SERVER+" but found "+top.getName());
      }
     
      Element keyStoreE = top.getFirstElementNamed(KEYSTORE);
View Full Code Here

      Reference testUser1Loc = new Reference(adminUserLoc.toString()+"testuser.1");
      response = client.handle(makeGet(testUser1Loc));
      assertTrue(response.getStatus().isSuccess());
      try {
         XMLRepresentationParser parser = new XMLRepresentationParser();
         Document doc = parser.load(response.getEntity());
         Element top = doc.getDocumentElement();
         assertTrue("testuser.1".equals(top.getAttributeValue("alias")));
      } catch (Exception ex) {
         fail("Exception on get user testuser.1 response: "+ex.getMessage());
      }
     
      response = client.handle(makePost(adminUserLoc,new StringRepresentation("<user xmlns='http://www.atomojo.org/Vocabulary/Admin/2007/1/0' alias='testuser.2' password='mypassword.2'/>",MediaType.APPLICATION_XML)));
      assertTrue(response.getStatus().isSuccess());
     
      Reference testUser2Loc = new Reference(adminUserLoc.toString()+"testuser.2");
      response = client.handle(makeGet(testUser2Loc));
      assertTrue(response.getStatus().isSuccess());
      try {
         XMLRepresentationParser parser = new XMLRepresentationParser();
         Document doc = parser.load(response.getEntity());
         Element top = doc.getDocumentElement();
         assertTrue("testuser.2".equals(top.getAttributeValue("alias")));
      } catch (Exception ex) {
         fail("I/O exception on get user testuser.1 response: "+ex.getMessage());
      }
     
      response = client.handle(makePost(testUser1Loc,new StringRepresentation("<user xmlns='http://www.atomojo.org/Vocabulary/Admin/2007/1/0' alias='testuser.1' password='mypassword.1.changed'><name>Test User</name></user>",MediaType.APPLICATION_XML)));
      assertTrue(response.getStatus().isSuccess());
     
      response = client.handle(makeGet(testUser1Loc));
      assertTrue(response.getStatus().isSuccess());
      try {
         XMLRepresentationParser parser = new XMLRepresentationParser();
         Document doc = parser.load(response.getEntity());
         Element top = doc.getDocumentElement();
         assertTrue("Test User".equals(top.getFirstElementNamed(Name.create("{http://www.atomojo.org/Vocabulary/Admin/2007/1/0}name")).getText()));
      } catch (Exception ex) {
         fail("Exception on get user testuser.1 response: "+ex.getMessage());
      }
     
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();
        
         Name [] roots = { AdminXML.NM_PUSH , AdminXML.NM_PULL };
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,roots));
         doc = dest.getDocument();
         Element top = doc.getDocumentElement();
         SyncProcess proc = new SyncProcess(db,top);
         if (proc.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
            return new StringRepresentation("Process with name "+proc.getName()+" already exists.");
         }
View Full Code Here

      Response response = client.handle(request);
      if (!response.getStatus().isSuccess()) {
         throw new AuthException("Failed to create user "+alias+", status="+response.getStatus().getCode());
      }
      try {
         Document userDoc = parser.load(response.getEntity());
         User user = createUser(cred,userDoc);
         userCache.put(alias,user);
         passwords.put(alias,password);
         return user;
      } catch (IOException ex) {
View Full Code Here

         // get groups
         Request request = new Request(Method.GET,groupsURL);
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
         Response response = client.handle(request);
         if (response.getStatus().isSuccess()) {
            Document groupsDoc = parser.load(response.getEntity());
            UUID uuid = UUID.fromString(top.getAttributeValue("id"));
            Element nameE = top.getFirstElementNamed(NAME);
            String name = nameE==null ? null : nameE.getText();
            Element emailE = top.getFirstElementNamed(EMAIL);
            String email = emailE==null ? null : emailE.getText();
            List<String> groups = new ArrayList<String>();
            Iterator<Element> groupElements = groupsDoc.getDocumentElement().getElementsByName(GROUP);
            while (groupElements.hasNext()) {
               groups.add(groupElements.next().getAttributeValue("alias"));
            }
            return new User(userAlias,uuid,name,email,groups);
         } else {
View Full Code Here

      Request request = new Request(Method.GET,userURL);
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
      Response response = client.handle(request);
      if (response.getStatus().isSuccess()) {
         try {
            Document userDoc = parser.load(response.getEntity());
            User user = createUser(cred,userDoc);
            return user;
         } catch (IOException ex) {
            throw new AuthException("I/O exception while communicating with auth service.",ex);
         } catch (XMLException ex) {
View Full Code Here

      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
      Response response = client.handle(request);
      if (response.getStatus().isSuccess()) {
         try {
            // TODO: this should stream...
            Document usersDoc = parser.load(response.getEntity());
            final Iterator<Element> users = usersDoc.getDocumentElement().getElementsByName(USER);
            return new Iterator<User>() {
               public boolean hasNext() {
                  return users.hasNext();
               }
               public void remove() {
                  throw new UnsupportedOperationException("remove() is not supported.");
               }
               public User next() {
                  Element userE = users.next();
                  String alias = userE.getAttributeValue("alias");
                  try {
                     User user = userCache.get(null,alias);
                     if (user==null) {
                        // get groups
                        String groupsURL = serviceBase.resolve("./users/a/"+alias+"/groups").toString();
                        Request request = new Request(Method.GET,groupsURL);
                        request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
                        Response response = client.handle(request);
                        if (response.getStatus().isSuccess()) {
                           try {
                              Document groupsDoc = parser.load(response.getEntity());
                              UUID uuid = UUID.fromString(userE.getAttributeValue("id"));
                              Element nameE = userE.getFirstElementNamed(NAME);
                              String name = nameE==null ? null : nameE.getText();
                              Element emailE = userE.getFirstElementNamed(EMAIL);
                              String email = emailE==null ? null : emailE.getText();
                              List<String> groups = new ArrayList<String>();
                              Iterator<Element> groupElements = groupsDoc.getDocumentElement().getElementsByName(GROUP);
                              while (groupElements.hasNext()) {
                                 groups.add(groupElements.next().getAttributeValue("alias"));
                              }
                              // we won't cache this
                              return new User(alias,uuid,name,email,groups);
View Full Code Here

      Request request = new Request(Method.GET,authURL);
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,alias,password));
      Response response = client.handle(request);
      if (response.getStatus().isSuccess()) {
         try {
            Document doc = parser.load(response.getEntity());
            user = parseUser(doc);
            User cachedUser = userCache.get(null, alias);
            if (cachedUser!=null) {
               user = cachedUser;
               passwords.put(user.getAlias(),password);
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.