Examples of OutputRepresentation


Examples of org.restlet.representation.OutputRepresentation

                  pipeline.passOption(optionName, new RuntimeValue(value));
               }
            }
         }
         final String outputPort = xproc.getPipeline().getOutputs().iterator().next();
         return new OutputRepresentation(MediaType.APPLICATION_XML) {
            public void write(OutputStream out) {
               try {
                  xproc.getPipeline().run();
                  Serialization serial = xproc.getPipeline().getSerialization(outputPort);              
                  WritableDocument doc = new WritableDocument(cache.getRuntime(),null,serial,out);
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

      this.app = new App(getContext().getLogger(),feed.getDB(),storage,theApp.getMetadataService());
   }
  
   public Representation get() {
      //getContext().getLogger().info("feed: "+feed.getName()+", id: "+feed.getId()+", parent: "+feed.getParentId());
      return new OutputRepresentation(MediaType.APPLICATION_ATOM) {
         public void write(OutputStream os)
            throws IOException
         {
            setCharacterSet(CharacterSet.UTF_8);
            try {
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

   }
  
   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      Representation rep = new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            try {
               Iterator<SyncProcess> procs = db.getSyncProcesses();
               Writer out = new OutputStreamWriter(os,"UTF-8");
               ItemDestination dest = new WriterItemDestination(out,"UTF-8");
               ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
               dest.send(constructor.createDocument());
               dest.send(constructor.createElement(AdminXML.NM_SYNC_PROCESSES));
               while (procs.hasNext()) {
                  SyncProcess proc = procs.next();
                  proc.marshall();
                  DocumentSource.generate(proc.getElement(),false,dest);
               }
               dest.send(constructor.createElementEnd(AdminXML.NM_SYNC_PROCESSES));
               dest.send(constructor.createDocumentEnd());
               out.flush();
               out.close();
            } catch (XMLException ex) {
               getContext().getLogger().log(Level.SEVERE,"Cannot get list of sync processes from DB: "+ex.getMessage(),ex);
               getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,"Cannot get list of sync processes due to XML DB error.");
            }
         }
      };
      rep.setCharacterSet(CharacterSet.UTF_8);
      return rep;
   }
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      final String name = getRequest().getAttributes().get("name").toString();

      Representation rep = new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            Writer out = new OutputStreamWriter(os,"UTF-8");
            out.write("<table name='"+name+"'>\n");
            try {
               DBConnection dbConnection = db.getConnection();
               try {
                  Statement s = dbConnection.getConnection().createStatement();
                  ResultSet r = s.executeQuery("select * from "+name);
                  ResultSetMetaData meta = r.getMetaData();
                  int columnCount = meta.getColumnCount();
                  out.write("<head>");
                  for (int i=1; i<=columnCount; i++) {
                     out.write("<name>");
                     out.write(meta.getColumnName(i));
                     out.write("</name>");
                  }
                  out.write("</head>\n");
                  while (r.next()) {
                     out.write("<row>");
                     for (int i=1; i<=columnCount; i++) {
                        String data = r.getString(i);
                        if (data!=null) {
                           out.write("<col>");
                           out.write(data);
                           out.write("</col>");
                        } else {
                           out.write("<col/>");
                        }
                     }
                     out.write("</row>\n");
                  }
               } finally {
                  db.release(dbConnection);
               }
            } catch (SQLException ex) {
               throw new IOException(ex.getMessage());
            }
            out.write("</table>");
            out.flush();
         }
      };
      rep.setCharacterSet(CharacterSet.UTF_8);
      return rep;
   }
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

  
   public Representation getRepresentation(Variant variant)
   {
      final Map<String,DBInfo> dbList = (Map<String,DBInfo>)getContext().getAttributes().get(DB_LIST);
      final Map<String,DBInfo> autodbList = (Map<String,DBInfo>)getContext().getAttributes().get(AUTO_DB_LIST);
      return new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            Writer out = new OutputStreamWriter(os,"UTF-8");
            out.write("<databases xmlns='"+AdminXML.NAMESPACE+"'>\n");
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

   }
  
   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      Representation rep = new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            try {
               Iterator<RemoteApp> apps = db.getRemoteApps();
               Writer out = new OutputStreamWriter(os,"UTF-8");
               ItemDestination dest = new WriterItemDestination(out,"UTF-8");
               ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
               dest.send(constructor.createDocument());
               dest.send(constructor.createElement(AdminXML.NM_APPS));
               while (apps.hasNext()) {
                  RemoteApp app = apps.next();
                  app.marshall();;
                  DocumentSource.generate(app.getElement(),false,dest);
               }
               dest.send(constructor.createElementEnd(AdminXML.NM_APPS));
               dest.send(constructor.createDocumentEnd());
               out.flush();
               out.close();
            } catch (XMLException ex) {
               getContext().getLogger().log(Level.SEVERE,"Cannot get list of remotes from DB: "+ex.getMessage(),ex);
               getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,"Cannot get list of remotes due to XML DB error.");
            }
         }
      };
      rep.setCharacterSet(CharacterSet.UTF_8);
      return rep;
   }
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

   }
  
   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      Representation rep = new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            try {
               Iterator<SyncTarget> targets = db.getSyncTargets();
               Writer out = new OutputStreamWriter(os,"UTF-8");
               ItemDestination dest = new WriterItemDestination(out,"UTF-8");
               ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
               dest.send(constructor.createDocument());
               dest.send(constructor.createElement(AdminXML.NM_TARGETS));
               while (targets.hasNext()) {
                  SyncTarget target = targets.next();
                  target.marshall();
                  DocumentSource.generate(target.getElement(),false,dest);
               }
               dest.send(constructor.createElementEnd(AdminXML.NM_TARGETS));
               dest.send(constructor.createDocumentEnd());
               out.flush();
               out.close();
            } catch (XMLException ex) {
               getContext().getLogger().log(Level.SEVERE,"Cannot get list of targets from DB: "+ex.getMessage(),ex);
               getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,"Cannot get list of targets due to XML DB error.");
            }
         }
      };
      rep.setCharacterSet(CharacterSet.UTF_8);
      return rep;
   }
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

   }
  
   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      return new OutputRepresentation(MediaType.APPLICATION_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            try {
               Writer out = new OutputStreamWriter(os,"UTF-8");
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      if (cookie!=null) {
         request.getCookies().add(cookie);
      }
      request.setEntity(new OutputRepresentation(MediaType.APPLICATION_ATOM_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            Writer w = new OutputStreamWriter(os,"UTF-8");
            try {
View Full Code Here

Examples of org.restlet.representation.OutputRepresentation

      this.resourceBase = resourceBase;
      this.app = app;
   }
  
   public Representation get() {
      return new OutputRepresentation(MediaType.APPLICATION_ATOM_XML) {
         public void write(OutputStream os)
            throws IOException
         {
            setCharacterSet(CharacterSet.UTF_8);
            try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.