Package org.infoset.xml

Examples of org.infoset.xml.Element


      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 void generate(ItemConstructor constructor,ItemDestination dest,boolean showPassword,boolean showRoles)
      throws XMLException
   {
      Element user = constructor.createElement(XML.USER_NAME);
      user.setAttributeValue("id",uuid.toString());
      if (alias!=null) {
         user.setAttributeValue("alias",alias);
      }
      if (showPassword) {
         try {
            String md5 = getEncryptedPassword();
            if (md5!=null) {
               user.setAttributeValue("password-md5",md5);
            }
         } catch (SQLException ex) {
            throw new XMLException("Cannot get password from database for user "+uuid,ex);
         }
      }
View Full Code Here

   }
  
   public void generate(ItemConstructor constructor,ItemDestination dest)
      throws XMLException
   {
      Element top = constructor.createElement(XML.PERMISSION_NAME);
      top.setAttributeValue("id",uuid.toString());
      top.setAttributeValue("name",name);
      dest.send(top);
      dest.send(constructor.createElementEnd(XML.PERMISSION_NAME));
   }
View Full Code Here

   }
  
   public void generate(ItemConstructor constructor,ItemDestination dest,boolean recurse)
      throws XMLException
   {
      Element top = constructor.createElement(XML.REALM_NAME);
      top.setAttributeValue("id",uuid.toString());
      top.setAttributeValue("name",name);
      dest.send(top);
      if (recurse) {
         try {
            dest.send(constructor.createCharacters("\n"));
            dest.send(constructor.createElement(XML.USERS_NAME));
View Full Code Here

         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.");
         }
         if (proc.getRemoteApp()==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The remote app service with name "+top.getAttributeValue("remote")+" does not exist.");
         }
         if (proc.getSyncTarget()==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The local target with name "+top.getAttributeValue("target")+" does not exist.");
         }
         if (proc.create()) {
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
            Reference ref = new Reference(getRequest().getResourceRef().toString()+"/"+proc.getName());
            getResponse().setLocationRef(ref);
View Full Code Here

   }
  
   User createUser(AuthCredentials cred,Document userDoc)
      throws AuthException,IOException,XMLException
   {
      Element top = userDoc.getDocumentElement();
      if (top.getName().equals(USER)) {

         String userAlias = top.getAttributeValue("alias");
         String groupsURL = serviceBase.resolve("./users/a/"+userAlias+"/groups").toString();
         // 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"));
            }
View Full Code Here

         return null;
      }
     
      try {
         Group group = fetch();
         Element top = doc.getDocumentElement();
         if (facet.equals(ROLE_FACET)) {
            if (top.getName().equals(XML.ROLE_NAME)) {
               String sid = top.getAttributeValue("id");
               String name = top.getAttributeValue("name");
               Role role = null;
               if (sid!=null) {
                  role = db.getRole(UUID.fromString(sid));
               }
               if (name!=null && role==null) {
                  role = db.getRole(name);
               }
               if (role==null) {
                  getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                  return new StringRepresentation("Cannot find role "+name);
               } else {
                  group.addRole(role);
                  getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
                  return null;
               }
            } else {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("Element "+top.getName()+" is not allowed.");
            }
         } else if (facet.equals(USER_FACET)) {
            if (top.getName().equals(XML.USER_NAME)) {
               String sid = top.getAttributeValue("id");
               String alias = top.getAttributeValue("alias");
               RealmUser user = null;
               if (sid!=null) {
                  UUID id = UUID.fromString(sid);
                  user = fetchUser(id);
               } else {
                  user = fetchUser(alias);
               }
               if (user==null) {
                  getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                  return new StringRepresentation("Cannot find user.");
               } else {
                  group.addMember(user);
                  getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
                  return null;
               }
            } else {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("Element "+top.getName()+" is not allowed.");
            }
         } else {
            getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
            return null;
         }
View Full Code Here

               }
               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"));
                              }
View Full Code Here

   }
  
   protected User parseUser(Document doc)
      throws AuthException
   {
      Element top = doc.getDocumentElement();
      if (top.getName().equals(SESSION)) {
         UUID uuid = UUID.fromString(top.getAttributeValue("user-id"));
         String userAlias = top.getAttributeValue("user-alias");
         Element nameE = top.getFirstElementNamed(NAME);
         String name = nameE==null ? null : nameE.getText();
         Element emailE = top.getFirstElementNamed(EMAIL);
         String email = emailE==null ? null : emailE.getText();
         // TODO: group is outdated.  It needs to be replaced
         List<String> groups = new ArrayList<String>();
         Iterator<Element> groupElements = top.getElementsByName(GROUP);
         while (groupElements.hasNext()) {
            groups.add(groupElements.next().getAttributeValue("alias"));
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.