Package org.atomojo.app.client

Examples of org.atomojo.app.client.XMLRepresentationParser


      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 postParser = XML.createParser();
      postParser.addAllowedElement(XML.PASSWORD_NAME);
     
      String password = null;
      try {
         DocumentDestination dest = new DocumentDestination();
         postParser.parse(entity,dest);
         password = dest.getDocument().getDocumentElement().getText();
      } catch (Exception ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("XML parse error: "+ex.getMessage());
      }
View Full Code Here


         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      final String name = getRequest().getAttributes().get("name").toString();
      XMLRepresentationParser parser = new XMLRepresentationParser();
      Document doc = null;
     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_APP));
         doc = dest.getDocument();
         RemoteApp app = new RemoteApp(db,doc.getDocumentElement());
         String lname = app.getName();
         if (!lname.equals(name)) {
            getResponse().setStatus(Status.CLIENT_ERROR_EXPECTATION_FAILED);
View Full Code Here

         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
     
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      final Storage storage = (Storage)getRequest().getAttributes().get(App.STORAGE_ATTR);
      XMLRepresentationParser parser = new XMLRepresentationParser();
      try {
         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) {
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();
     
      try {
         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_BACKUP));
         Document doc = dest.getDocument();
        
         Element top = doc.getDocumentElement();
         String location = top.getAttributeValue("location");
         if (location==null) {
View Full Code Here

         throw new RuntimeException("Cannot find auth.xsd relative to class path.");
      }
   }
  
   public static XMLRepresentationParser createParser() {
      XMLRepresentationParser parser = new XMLRepresentationParser();
      parser.addNamespaceLocation(authNS,authXSD);
      parser.setValidation(true);
      return parser;
   }
View Full Code Here

      } else {
         Request request = new Request(Method.GET,service);
         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);
View Full Code Here

         }
      }
      final Set<String> paths = additive ? null : new TreeSet<String>();
      try {
         client.introspect(new IntrospectionClient.ServiceListener() {
            XMLRepresentationParser parser = new XMLRepresentationParser();
            int workspaceCount = 0;
            public void onStartWorkspace(String title) {
               // TODO: handle more than one workspace
               workspaceCount++;
               log.info("Workspace: "+workspaceCount);
View Full Code Here

   }
  
   public void parse()
      throws IOException,XMLException
   {
      XMLRepresentationParser parser = new XMLRepresentationParser();
      xml = parser.load(getRepresentation()).getDocumentElement();
   }
View Full Code Here

      copy(sourceRoot,targetParent,targetName);
   }
  
   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);
View Full Code Here

TOP

Related Classes of org.atomojo.app.client.XMLRepresentationParser

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.