List of usage examples for javax.servlet ServletOutputStream println
public void println(double d) throws IOException
double
value to the client, followed by a carriage return-line feed (CRLF). From source file:pivotal.au.se.gemfirexdweb.controller.CreateTypeController.java
@RequestMapping(value = "/createtype", method = RequestMethod.POST) public String createTypeAction(@ModelAttribute("typeAttribute") Type typeAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {// w ww .ja va2 s.co m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for create UDT (Type)"); String schema = typeAttribute.getSchemaName().trim(); if (schema.length() == 0) { schema = (String) session.getAttribute("schema"); } logger.debug("New Type schema name = " + schema); logger.debug("New Type name = " + typeAttribute.getTypeName()); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer createType = new StringBuffer(); createType.append("CREATE TYPE " + schema + "." + typeAttribute.getTypeName() + " \n"); createType.append("EXTERNAL NAME '" + typeAttribute.getJavaClassName() + "' \n"); createType.append("LANGUAGE JAVA \n"); if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating UDT Type as -> " + createType.toString()); result = GemFireXDWebDAOUtil.runCommand(createType.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create UDT (Type) SQL as follows as -> " + createType.toString()); model.addAttribute("sql", createType.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, typeAttribute.getTypeName())); ServletOutputStream out = response.getOutputStream(); out.println(createType.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-type.jsp return "create-type"; }
From source file:pivotal.au.se.gemfirexdweb.controller.AddLoaderController.java
@RequestMapping(value = "/addloader", method = RequestMethod.POST) public String createLoaderAction(@ModelAttribute("loaderAttribute") AddLoader loaderAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from w w w . j a v a2 s . c om*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for Table Loader"); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer addLoader = new StringBuffer(); addLoader.append("CALL SYS.ATTACH_LOADER ('" + loaderAttribute.getSchemaName() + "', \n"); addLoader.append("'" + loaderAttribute.getTableName() + "', \n"); addLoader.append("'" + loaderAttribute.getFunctionName() + "', \n"); if (!checkIfParameterEmpty(request, "initInfoString")) { addLoader.append("'" + loaderAttribute.getInitInfoString() + "') \n"); } else { addLoader.append("NULL) \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Table Loader as -> " + addLoader.toString()); result = GemFireXDWebDAOUtil.runStoredCommand(addLoader.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Table Loader SQL as follows as -> " + addLoader.toString()); model.addAttribute("sql", addLoader.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, loaderAttribute.getTableName() + "-Loader")); ServletOutputStream out = response.getOutputStream(); out.println(addLoader.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/addloader.jsp return "addloader"; }
From source file:org.ms123.common.exporting.BaseExportingServiceImpl.java
public Map smooksExport(String storeId, String entityName, Map filters, Map options, HttpServletResponse response) throws Exception { StoreDesc sdesc = StoreDesc.get(storeId); response.setContentType("application/xml;charset=UTF-8"); Map filtersMap = filters;//from ww w . j a va 2 s .c om response.addHeader("Content-Disposition", "attachment;filename=\"" + options.get("filename") + "\""); Smooks smooks = m_smooksFactory.createInstance(); ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(m_nucleusService.getClassLoader(sdesc)); System.out.println("filtersMap:" + filtersMap); System.out.println("mainEntity:" + entityName); System.out.println("options:" + options); try { SessionContext sessionContext = m_dataLayer.getSessionContext(sdesc); List result = sessionContext.query(entityName, filtersMap); System.out.println("result:" + result); Class clazz = m_nucleusService.getClass(sdesc, m_inflector.getClassName(entityName)); List nList = new ArrayList(); nList.addAll(result); GenericReaderConfigurator grc = new GenericReaderConfigurator(BeanReader.class); smooks.setReaderConfig(grc); ExecutionContext executionContext = smooks.createExecutionContext(); executionContext.setAttribute("sessionContext", sessionContext); executionContext.setAttribute("moduleName", entityName); executionContext.setAttribute("withNullValues", options.get("withNullValues")); JavaSource source = new JavaSource("result", nList); ServletOutputStream outputStream = response.getOutputStream(); outputStream.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); smooks.filterSource(executionContext, source, new StreamResult(outputStream)); return new HashMap(); } finally { smooks.close(); Thread.currentThread().setContextClassLoader(previous); } }
From source file:org.loklak.api.admin.CrawlerServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Query post = RemoteAccess.evaluate(request); boolean localhost = post.isLocalhostAccess(); String callback = post.get("callback", ""); boolean jsonp = callback != null && callback.length() > 0; String[] incubation = post.get("start", new String[0], ","); int depth = Math.min(localhost ? 8 : 1, post.get("depth", 0)); boolean hashtags = post.get("hashtags", true); boolean users = post.get("users", true); for (String query : incubation) Crawler.stack(query, depth, hashtags, users, true); post.setResponse(response, "application/javascript"); // generate json JSONObject json = new JSONObject(true); if (incubation == null || incubation.length == 0) json.put("_hint", "start a crawl: start=<terms, comma-separated>, depth=<crawl depth> (dflt: 0), hashtags=<true|false> (dflt: true), users=<true|false> (dflt: true)"); if (!localhost) json.put("_hint", "you are connecting from a non-localhost client " + post.getClientHost() + " , depth is limited to 1"); JSONObject index_sizes = new JSONObject(true); json.put("index_sizes", index_sizes); index_sizes.put("messages", DAO.countLocalMessages(-1)); index_sizes.put("users", DAO.countLocalUsers()); json.put("crawler_status", Crawler.toJSON()); // write json ServletOutputStream sos = response.getOutputStream(); if (jsonp)/*from www. j ava2s . com*/ sos.print(callback + "("); sos.print(json.toString(2)); if (jsonp) sos.println(");"); sos.println(); post.finalize(); }
From source file:pivotal.au.se.gemfirexdweb.controller.AddWriterController.java
@RequestMapping(value = "/addwriter", method = RequestMethod.POST) public String createWriterAction(@ModelAttribute("writerAttribute") AddWriter writerAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from ww w . j av a2 s. c om Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for Table Writer"); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer addWriter = new StringBuffer(); addWriter.append("CALL SYS.ATTACH_WRITER ('" + writerAttribute.getSchemaName() + "', \n"); addWriter.append("'" + writerAttribute.getTableName() + "', \n"); addWriter.append("'" + writerAttribute.getFunctionString() + "', \n"); if (!checkIfParameterEmpty(request, "initInfoString")) { addWriter.append("'" + writerAttribute.getInitInfoString() + "', \n"); } else { addWriter.append("NULL, \n"); } if (!checkIfParameterEmpty(request, "serverGroups")) { addWriter.append("'" + writerAttribute.getServerGroups() + "')"); } else { addWriter.append("NULL), \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Table Writer as -> " + addWriter.toString()); result = GemFireXDWebDAOUtil.runStoredCommand(addWriter.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Table Writer SQL as follows as -> " + addWriter.toString()); model.addAttribute("sql", addWriter.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, writerAttribute.getTableName() + "-Writer")); ServletOutputStream out = response.getOutputStream(); out.println(addWriter.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/addwriter.jsp return "addwriter"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateSchemaController.java
@RequestMapping(value = "/createschema", method = RequestMethod.POST) public String createSchemaAction(@ModelAttribute("schemaAttribute") NewSchema schemaAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/* ww w. j a va 2s .c om*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for create Schema"); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); String schema = schemaAttribute.getSchemaName(); logger.debug("New Schema name = " + schema); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer createSchema = new StringBuffer(); createSchema.append("CREATE SCHEMA "); if (!checkIfParameterEmpty(request, "authorizationSchema")) { createSchema.append("AUTHORIZATION " + schemaAttribute.getAuthorizationSchema() + " \n"); } else { createSchema.append(schema + " \n"); } if (!checkIfParameterEmpty(request, "serverGroups")) { createSchema.append("DEFAULT SERVER GROUPS (" + schemaAttribute.getServerGroups() + ") \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Schema as -> " + createSchema.toString()); result = GemFireXDWebDAOUtil.runCommand(createSchema.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); model.addAttribute("chosenSchema", schemaAttribute.getAuthorizationSchema()); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Schema SQL as follows as -> " + createSchema.toString()); model.addAttribute("sql", createSchema.toString()); model.addAttribute("chosenSchema", schemaAttribute.getAuthorizationSchema()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, schemaAttribute.getSchemaName())); ServletOutputStream out = response.getOutputStream(); out.println(createSchema.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-schema.jsp return "create-schema"; }
From source file:pivotal.au.se.gemfirexdweb.controller.AddListenerController.java
@RequestMapping(value = "/addlistener", method = RequestMethod.POST) public String createListenerAction(@ModelAttribute("listenerAttribute") AddListener listenerAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from ww w . ja v a 2 s. c o m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for add listener"); logger.debug("Listener ID = " + listenerAttribute.getId()); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer addListener = new StringBuffer(); addListener.append("CALL SYS.ADD_LISTENER ('" + listenerAttribute.getId() + "', \n"); addListener.append("'" + listenerAttribute.getSchemaName() + "', \n"); addListener.append("'" + listenerAttribute.getTableName() + "', \n"); addListener.append("'" + listenerAttribute.getFunctionName() + "', \n"); if (!checkIfParameterEmpty(request, "initString")) { addListener.append("'" + listenerAttribute.getInitString() + "', \n"); } else { addListener.append("'', \n"); } if (!checkIfParameterEmpty(request, "serverGroups")) { addListener.append("'" + listenerAttribute.getServerGroups() + "')"); } else { addListener.append("''), \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Listener as -> " + addListener.toString()); result = GemFireXDWebDAOUtil.runStoredCommand(addListener.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); model.addAttribute("tableName", listenerAttribute.getTableName()); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Listener SQL as follows as -> " + addListener.toString()); model.addAttribute("sql", addListener.toString()); model.addAttribute("tableName", listenerAttribute.getTableName()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, listenerAttribute.getId())); ServletOutputStream out = response.getOutputStream(); out.println(addListener.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/addlistener.jsp return "addlistener"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateDiskStoreController.java
@RequestMapping(value = "/creatediskstore", method = RequestMethod.POST) public String createHDFSStoreAction(@ModelAttribute("diskStoreAttribute") NewDiskStore diskStoreAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from w ww . j a v a2 s .c om*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for create Disk Store"); String diskStoreName = diskStoreAttribute.getDiskStoreName(); logger.debug("New Disk Store Name = " + diskStoreName); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer createDiskStore = new StringBuffer(); createDiskStore.append("create DISKSTORE " + diskStoreName + " \n"); if (!checkIfParameterEmpty(request, "maxLogSize")) { createDiskStore.append("MAXLOGSIZE " + diskStoreAttribute.getMaxLogSize() + " \n"); } if (!checkIfParameterEmpty(request, "autoCompact")) { createDiskStore.append("AUTOCOMPACT " + diskStoreAttribute.getAutoCompact() + " \n"); } if (!checkIfParameterEmpty(request, "allowForceCompaction")) { createDiskStore .append("ALLOWFORCECOMPACTION " + diskStoreAttribute.getAllowForceCompaction() + " \n"); } if (!checkIfParameterEmpty(request, "compactionThreshold")) { createDiskStore .append("COMPACTIONTHRESHOLD " + diskStoreAttribute.getCompactionThreshold() + " \n"); } if (!checkIfParameterEmpty(request, "timeInterval")) { createDiskStore.append("TIMEINTERVAL " + diskStoreAttribute.getTimeInterval() + " \n"); } if (!checkIfParameterEmpty(request, "writeBufferSize")) { createDiskStore.append("WRITEBUFFERSIZE " + diskStoreAttribute.getWriteBufferSize() + " \n"); } if (!checkIfParameterEmpty(request, "additionalParams")) { createDiskStore.append(diskStoreAttribute.getAdditionalParams()); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating disk store as -> " + createDiskStore.toString()); result = GemFireXDWebDAOUtil.runCommand(createDiskStore.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Disk Store SQL as follows as -> " + createDiskStore.toString()); model.addAttribute("sql", createDiskStore.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, diskStoreName)); ServletOutputStream out = response.getOutputStream(); out.println(createDiskStore.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-diskstore.jsp return "create-diskstore"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateSynonymController.java
@RequestMapping(value = "/createsynonym", method = RequestMethod.POST) public String createSynonymAction(@ModelAttribute("synonymAttribute") NewSynonym synonymAttribute, Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from w ww . ja va2s .c o m*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to action an event for create synonym"); String schema = synonymAttribute.getSchemaName().trim(); if (schema.length() == 0) { schema = (String) session.getAttribute("schema"); } logger.debug("New synonym name = " + synonymAttribute.getSynonymName()); TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO(); ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO(); List<View> views = viewDAO.retrieveViewList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); model.addAttribute("views", views); List<Table> tbls = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key"), "ORDINARY"); model.addAttribute("tables", tbls); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer createSynonym = new StringBuffer(); createSynonym.append("CREATE SYNONYM " + schema + "." + synonymAttribute.getSynonymName() + " \n"); createSynonym.append("FOR " + synonymAttribute.getObjectName() + " \n"); if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating synonym as -> " + createSynonym.toString()); result = GemFireXDWebDAOUtil.runCommand(createSynonym.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create UDT (Type) SQL as follows as -> " + createSynonym.toString()); model.addAttribute("sql", createSynonym.toString()); model.addAttribute("objectName", request.getParameter("objectName")); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, synonymAttribute.getSynonymName())); ServletOutputStream out = response.getOutputStream(); out.println(createSynonym.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-synonym.jsp return "create-synonym"; }
From source file:opendap.wcs.v1_1_2.http.Attachment.java
/** * Write the attchment to the indicated stream * * @param mimeBoundary MIME Boundary for the attachment. * @param sos Stream to which to write the attachment. * @throws IOException When things can't be read or written. * @throws java.net.URISyntaxException If the target URL is hosed. *//*from w w w.ja v a 2 s .co m*/ public void write(String mimeBoundary, ServletOutputStream sos) throws IOException, URISyntaxException { sos.println("--" + mimeBoundary); sos.println("Content-Type: " + contentType); sos.println("Content-Transfer-Encoding: " + contentTransferEncoding); sos.println("Content-Id: <" + contentId + ">"); sos.println(); switch (_myContentModel) { case stream: try { drainInputStream(_istream, sos); } finally { if (_istream != null) { try { _istream.close(); } catch (IOException e) { log.error("Failed to close content source InputStream. " + "Error Message: " + e.getMessage()); } } } break; case url: forwardUrlContent(_sourceUrl, sos); break; case document: sendDocument(sos); break; default: break; } //MIME Attachments need to end with a newline! sos.println(); }