List of usage examples for java.text DateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:org.codice.ddf.spatial.kml.transformer.KMLTransformerImpl.java
/** * The default Transformation from a {@link Metacard} to a KML {@link Placemark}. Protected to * easily allow other default transformations. * * @param entry//from w w w .j a v a 2 s. c o m * - the {@link Metacard} to transform. * @param urlToMetacard * @return * @throws javax.xml.transform.TransformerException */ protected Placemark performDefaultTransformation(Metacard entry, String url) throws CatalogTransformerException { // wrap metacard to work around classLoader/reflection issues entry = new MetacardImpl(entry); Placemark kmlPlacemark = KmlFactory.createPlacemark(); kmlPlacemark.setId("Placemark-" + entry.getId()); kmlPlacemark.setName(entry.getTitle()); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String effectiveTime = null; if (entry.getEffectiveDate() == null) { effectiveTime = dateFormat.format(new Date()); } else { effectiveTime = dateFormat.format(entry.getEffectiveDate()); } TimeSpan timeSpan = KmlFactory.createTimeSpan(); timeSpan.setBegin(effectiveTime); kmlPlacemark.setTimePrimitive(timeSpan); kmlPlacemark.setGeometry(getKmlGeoFromWkt(entry.getLocation())); String description = entry.getTitle(); Handlebars handlebars = new Handlebars(templateLoader); handlebars.registerHelpers(templateHelper); try { Template template = handlebars.compile(DESCRIPTION_TEMPLATE); description = template.apply(new HandlebarsMetacard(entry)); LOGGER.debug(description); } catch (IOException e) { LOGGER.error("Failed to apply description Template", e); } kmlPlacemark.setDescription(description); String styleUrl = styleMapper.getStyleForMetacard(entry); if (StringUtils.isNotBlank(styleUrl)) { kmlPlacemark.setStyleUrl(styleUrl); } return kmlPlacemark; }
From source file:com.appeligo.showfiles.ShowFile.java
/** * @param request/*from w w w . ja v a2 s .c om*/ * @param out * @param path * @param f */ private void listFiles(HttpServletRequest request, PrintWriter out, String path, File f) { header(out, path); String[] filenames = f.list(); Arrays.sort(filenames); for (int i = 0; i < filenames.length; i++) { String filename = filenames[i]; String fullPathname = documentRoot + path + "/" + filename; File child = new File(fullPathname); if (child.isHidden()) { continue; } if (filename.endsWith(".flv")) { if (new File(fullPathname.replace(".flv", ".html.gz")).exists()) { continue; } } filename = filename.replace(":", "%3a"); if (!path.endsWith("/")) { path = path + "/"; } String displayName = filenames[i]; if (child.isDirectory()) { displayName += "/"; if (!filename.endsWith("/")) { filename = filename + "/"; } } if (filename.endsWith(".html.gz")) { if (new File(fullPathname.replace(".html.gz", ".flv")).exists()) { out.println("<a href=\"" + request.getContextPath() + "/ShowFlv" + //request.getServletPath()+ path + filename.replace(".html.gz", ".flv") + "\">" + "<img src=\"" + request.getContextPath() + "/skins/default/videoIcon.gif\" alt=\"video\"/>" + "</a>"); } String tsString = filename.substring(0, filename.indexOf('.')); try { long timestamp = Long.parseLong(tsString); DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT); df.setTimeZone(TimeZone.getTimeZone("GMT")); String time = df.format(new Date(timestamp)) + " - "; if (time.indexOf(':') == 1) { time = "0" + time; } out.print(time); } catch (NumberFormatException e) { } } else if (filename.endsWith(".flv") && (filename.indexOf(",") > 0)) { showPreview(request, out, path, filename); } out.print("<a href=\"" + request.getContextPath() + request.getServletPath() + path + filename + "\">" + displayName + "</a>"); if (filename.endsWith(".html.gz")) { BufferedReader r; try { r = new BufferedReader( new InputStreamReader(new GZIPInputStream(new FileInputStream(fullPathname)))); String line; while ((line = r.readLine()) != null) { if (line.startsWith("<title>")) { int nextLT = line.indexOf('<', 7); String title = line.substring(7, nextLT); out.print(" " + title); break; } } r.close(); } catch (FileNotFoundException e) { } catch (IOException e) { } } out.println("<br/>"); } footer(out); }
From source file:com.krawler.common.notification.handlers.NotificationExtractorManager.java
public void extractAndSendNotificationDefination(NotificationRequest notificationReqObj, NotificationDefinition notifyDef, Map<String, Object> extraParams) { try {/* w ww. j av a2 s. c om*/ Set<Recepients> recepients = notificationReqObj.getRecepients(); for (Recepients receiver : recepients) { User receiverUser = receiver.getUserid(); KWLTimeZone timeZone = authHandler.getTZforUser(receiverUser, receiverUser.getCompany(), null); DateFormat df = new SimpleDateFormat("MMMM d, yyyy");//authHandler.getDateFormatter(); String tZStr = timeZone.getDifference(); if (tZStr != null) { TimeZone zone = TimeZone.getTimeZone("GMT" + tZStr); df.setTimeZone(zone); } StringBuffer htmlMsg = new StringBuffer(notifyDef.getMessage1()); replacePlaceholders(htmlMsg, notificationReqObj, receiverUser, df); if (extraParams.containsKey(Constants.VARIABLEDATA) && extraParams.get(Constants.VARIABLEDATA) != null) { htmlMsg.toString().replaceAll(Constants.VARIABLEDATA, extraParams.get(Constants.VARIABLEDATA).toString()); } replaceExtraPlaceHolders(htmlMsg, extraParams); StringBuffer subject = new StringBuffer(notifyDef.getSubject()); replaceExtraPlaceHolders(subject, extraParams); replacePlaceholders(subject, notificationReqObj, receiverUser, df); User sender = (User) commonTablesDAOObj.getObject(Constants.USERS_CLASSPATH, notificationReqObj.getCreatedbyid()); // load placeholder class try { SimpleEmailNotification mail = new SimpleEmailNotification(sender.getEmailID(), new String[] { receiverUser.getEmailID() }, subject.toString(), htmlMsg.toString()); mail.setSenderCache(senderCache); mail.send(); // update status as "SENT" = 1; notifyServiceDAO.updateRecipientStatus(receiver.getId(), Long.parseLong(String.valueOf(NOTIFICATIONSTATUS.SENT.ordinal()))); } catch (Exception ex) { LOG.info(ex.getMessage(), ex); ex.printStackTrace(); } } } catch (Exception ex) { LOG.info(ex.getMessage(), ex); ex.printStackTrace(); } }
From source file:HardcopyWriter.java
/** * The constructor for this class has a bunch of arguments: The frame argument * is required for all printing in Java. The jobname appears left justified at * the top of each printed page. The font size is specified in points, as * on-screen font sizes are. The margins are specified in inches (or fractions * of inches)./*from w w w .j a v a2s . c om*/ */ public HardcopyWriter(Frame frame, String jobname, int fontsize, double leftmargin, double rightmargin, double topmargin, double bottommargin) throws HardcopyWriter.PrintCanceledException { // Get the PrintJob object with which we'll do all the printing. // The call is synchronized on the static printprops object, which // means that only one print dialog can be popped up at a time. // If the user clicks Cancel in the print dialog, throw an exception. Toolkit toolkit = frame.getToolkit(); // get Toolkit from Frame synchronized (printprops) { job = toolkit.getPrintJob(frame, jobname, printprops); } if (job == null) throw new PrintCanceledException("User cancelled print request"); pagesize = job.getPageDimension(); // query the page size pagedpi = job.getPageResolution(); // query the page resolution // Bug Workaround: // On windows, getPageDimension() and getPageResolution don't work, so // we've got to fake them. if (System.getProperty("os.name").regionMatches(true, 0, "windows", 0, 7)) { // Use screen dpi, which is what the PrintJob tries to emulate pagedpi = toolkit.getScreenResolution(); // Assume a 8.5" x 11" page size. A4 paper users must change this. pagesize = new Dimension((int) (8.5 * pagedpi), 11 * pagedpi); // We also have to adjust the fontsize. It is specified in points, // (1 point = 1/72 of an inch) but Windows measures it in pixels. fontsize = fontsize * pagedpi / 72; } // Compute coordinates of the upper-left corner of the page. // I.e. the coordinates of (leftmargin, topmargin). Also compute // the width and height inside of the margins. x0 = (int) (leftmargin * pagedpi); y0 = (int) (topmargin * pagedpi); width = pagesize.width - (int) ((leftmargin + rightmargin) * pagedpi); height = pagesize.height - (int) ((topmargin + bottommargin) * pagedpi); // Get body font and font size font = new Font("Monospaced", Font.PLAIN, fontsize); metrics = frame.getFontMetrics(font); lineheight = metrics.getHeight(); lineascent = metrics.getAscent(); charwidth = metrics.charWidth('0'); // Assumes a monospaced font! // Now compute columns and lines will fit inside the margins chars_per_line = width / charwidth; lines_per_page = height / lineheight; // Get header font information // And compute baseline of page header: 1/8" above the top margin headerfont = new Font("SansSerif", Font.ITALIC, fontsize); headermetrics = frame.getFontMetrics(headerfont); headery = y0 - (int) (0.125 * pagedpi) - headermetrics.getHeight() + headermetrics.getAscent(); // Compute the date/time string to display in the page header DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); df.setTimeZone(TimeZone.getDefault()); time = df.format(new Date()); this.jobname = jobname; // save name this.fontsize = fontsize; // save font size }
From source file:com.rogchen.common.xml.UtilDateTime.java
public static String toGmtTimestampString(Timestamp timestamp) { DateFormat df = DateFormat.getDateTimeInstance(); df.setTimeZone(TimeZone.getTimeZone("GMT")); return df.format(timestamp); }
From source file:org.apache.falcon.lifecycle.TableStorageFeedEvictorIT.java
private List<HCatPartition> getFilteredPartitions(String tableName, String timeZone, String dateMask, Pair<Date, Date> range) throws HCatException { DateFormat dateFormat = new SimpleDateFormat(dateMask); dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); String filter = "ds < '" + dateFormat.format(range.first) + "'"; return client.listPartitionsByFilter(DATABASE_NAME, tableName, filter); }
From source file:com.clustercontrol.jmx.factory.RunMonitorJmx.java
/** * JMX ??//from w w w . j av a 2s . c o m * * @param facilityId ID * @return ???????true */ @Override public boolean collect(String facilityId) { boolean result = false; if (m_now != null) { m_nodeDate = m_now.getTime(); } m_value = 0; exception = null; NodeInfo node = null; if (!m_isMonitorJob) { node = nodeInfo.get(facilityId); } else { try { // ?? node = new RepositoryControllerBean().getNode(facilityId); } catch (Exception e) { m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NODE_ATTRIBUTES.getMessage(); return false; } } JMXServiceURL url = null; try { String rmiFormat = HinemosPropertyUtil.getHinemosPropertyStr("monitor.jmx.rmi.format", "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi"); String urlStr = String.format(rmiFormat, node.getAvailableIpAddress(), jmx.getPort()); m_log.debug("facilityId=" + facilityId + ", url=" + urlStr); url = new JMXServiceURL(urlStr); } catch (Exception e) { m_log.warn("fail to initialize JMXServiceURL : " + e.getMessage() + " (" + e.getClass().getName() + ")", e); exception = e; return result; } JMXConnector jmxc = null; try { Map<String, Object> env = new HashMap<>(); if (jmx.getAuthUser() != null) env.put(JMXConnector.CREDENTIALS, new String[] { jmx.getAuthUser(), jmx.getAuthPassword() }); System.setProperty("sun.rmi.transport.tcp.responseTimeout", Integer.toString(HinemosPropertyUtil .getHinemosPropertyNum("system.sun.rmi.transport.tcp.responseTimeout", Long.valueOf(10 * 1000)) .intValue())); jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); JmxMasterInfo jmxMasterInfo = QueryUtil.getJmxMasterInfoPK(jmx.getMasterId()); Object value = mbsc.getAttribute(new ObjectName(jmxMasterInfo.getObjectName()), jmxMasterInfo.getAttributeName()); m_value = Double.parseDouble( searchTargetValue(value, Arrays.asList(KeyParser.parseKeys(jmxMasterInfo.getKeys()))) .toString()); // ?? if (m_convertFlg == ConvertValueConstant.TYPE_DELTA) { // ?? MonitorJmxValue valueEntity = null; Double prevValue = 0d; Long prevDate = 0l; if (!m_isMonitorJob) { // ?? // cache?? valueEntity = MonitorJmxCache.getMonitorJmxValue(m_monitorId, facilityId); // ??? prevValue = valueEntity.getValue(); if (valueEntity.getGetDate() != null) { prevDate = valueEntity.getGetDate(); } } else { // ?? valueEntity = new MonitorJmxValue(new MonitorJmxValuePK(m_monitorId, facilityId)); if (m_prvData instanceof MonitorJmxValue) { // ???? prevValue = ((MonitorJmxValue) m_prvData).getValue(); prevDate = ((MonitorJmxValue) m_prvData).getGetDate(); } } // JMX???? valueEntity.setValue(Double.valueOf(m_value)); valueEntity.setGetDate(m_nodeDate); if (!m_isMonitorJob) { // ???ID????? if (m_monitor.getMonitorFlg()) MonitorJmxCache.update(m_monitorId, facilityId, valueEntity); int m_validSecond = HinemosPropertyUtil .getHinemosPropertyNum("monitor.jmx.valid.second", Long.valueOf(15)).intValue(); // ??????????? int tolerance = (m_runInterval + m_validSecond) * 1000; if (prevDate > m_nodeDate - tolerance) { // ??null??? if (prevValue == null) { m_log.debug("collect() : prevValue is null"); m_prevNullchk = true; return false; } m_value = m_value - prevValue; } else { if (prevDate != 0l) { DateFormat df = DateFormat.getDateTimeInstance(); df.setTimeZone(HinemosTime.getTimeZone()); String[] args = { df.format(new Date(prevDate)) }; m_message = MessageConstant.MESSAGE_TOO_OLD_TO_CALCULATE.getMessage(args); return false; } else { // ???0?? m_nodeDate = 0l; } } } else { m_value = m_value - prevValue; m_curData = valueEntity; } } m_log.debug(jmxMasterInfo.getName() + " : " + m_value + " " + jmxMasterInfo.getMeasure()); result = true; } catch (NumberFormatException e) { m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); String[] args = { Double.toString(m_value) }; m_message = MessageConstant.MESSAGE_COULD_NOT_GET_NUMERIC_VALUE.getMessage(args); return false; } catch (Exception e) { String message = e.getMessage(); if (message != null) { message = message.replaceAll("\n", ""); } m_log.warn("fail to access JMXService : " + message + " (" + e.getClass().getName() + ")"); exception = e; } finally { try { if (jmxc != null) { jmxc.close(); } } catch (IOException e) { m_log.info("fail to close JMXService : " + e.getMessage() + " (" + e.getClass().getName() + ")"); exception = e; } } return result; }
From source file:org.apache.nifi.processors.orc.PutORCTest.java
@Test public void testWriteORCWithAvroLogicalTypes() throws IOException, InitializationException { final String avroSchema = IOUtils.toString( new FileInputStream("src/test/resources/user_logical_types.avsc"), StandardCharsets.UTF_8); schema = new Schema.Parser().parse(avroSchema); Calendar now = Calendar.getInstance(); LocalTime nowTime = LocalTime.now(); LocalDateTime nowDateTime = LocalDateTime.now(); LocalDate epoch = LocalDate.ofEpochDay(0); LocalDate nowDate = LocalDate.now(); final int timeMillis = nowTime.get(ChronoField.MILLI_OF_DAY); final Timestamp timestampMillis = Timestamp.valueOf(nowDateTime); final Date dt = Date.valueOf(nowDate); final double dec = 1234.56; configure(proc, 10, (numUsers, readerFactory) -> { for (int i = 0; i < numUsers; i++) { readerFactory.addRecord(i, timeMillis, timestampMillis, dt, dec); }/*w ww . j a va2s .c om*/ return null; }); final String filename = "testORCWithDefaults-" + System.currentTimeMillis(); final Map<String, String> flowFileAttributes = new HashMap<>(); flowFileAttributes.put(CoreAttributes.FILENAME.key(), filename); testRunner.setProperty(PutORC.HIVE_TABLE_NAME, "myTable"); testRunner.enqueue("trigger", flowFileAttributes); testRunner.run(); testRunner.assertAllFlowFilesTransferred(PutORC.REL_SUCCESS, 1); final Path orcFile = new Path(DIRECTORY + "/" + filename); // verify the successful flow file has the expected attributes final MockFlowFile mockFlowFile = testRunner.getFlowFilesForRelationship(PutORC.REL_SUCCESS).get(0); mockFlowFile.assertAttributeEquals(PutORC.ABSOLUTE_HDFS_PATH_ATTRIBUTE, orcFile.getParent().toString()); mockFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), filename); mockFlowFile.assertAttributeEquals(PutORC.RECORD_COUNT_ATTR, "10"); // DDL will be created with field names normalized (lowercased, e.g.) for Hive by default mockFlowFile.assertAttributeEquals(PutORC.HIVE_DDL_ATTRIBUTE, "CREATE EXTERNAL TABLE IF NOT EXISTS `myTable` (`id` INT, `timemillis` INT, `timestampmillis` TIMESTAMP, `dt` DATE, `dec` DOUBLE) STORED AS ORC"); // verify we generated a provenance event final List<ProvenanceEventRecord> provEvents = testRunner.getProvenanceEvents(); assertEquals(1, provEvents.size()); // verify it was a SEND event with the correct URI final ProvenanceEventRecord provEvent = provEvents.get(0); assertEquals(ProvenanceEventType.SEND, provEvent.getEventType()); // If it runs with a real HDFS, the protocol will be "hdfs://", but with a local filesystem, just assert the filename. Assert.assertTrue(provEvent.getTransitUri().endsWith(DIRECTORY + "/" + filename)); // verify the content of the ORC file by reading it back in verifyORCUsers(orcFile, 10, (x, currUser) -> { assertEquals((int) currUser, ((IntWritable) x.get(0)).get()); assertEquals(timeMillis, ((IntWritable) x.get(1)).get()); assertEquals(timestampMillis, ((TimestampWritableV2) x.get(2)).getTimestamp().toSqlTimestamp()); final DateFormat noTimeOfDayDateFormat = new SimpleDateFormat("yyyy-MM-dd"); noTimeOfDayDateFormat.setTimeZone(TimeZone.getTimeZone("gmt")); assertEquals(noTimeOfDayDateFormat.format(dt), ((DateWritableV2) x.get(3)).get().toString()); assertEquals(dec, ((DoubleWritable) x.get(4)).get(), Double.MIN_VALUE); return null; }); // verify we don't have the temp dot file after success final File tempOrcFile = new File(DIRECTORY + "/." + filename); Assert.assertFalse(tempOrcFile.exists()); // verify we DO have the CRC file after success final File crcAvroORCFile = new File(DIRECTORY + "/." + filename + ".crc"); Assert.assertTrue(crcAvroORCFile.exists()); }
From source file:org.apache.falcon.lifecycle.TableStorageFeedEvictorIT.java
private void verifyFSPartitionsAreDeleted(List<String> candidatePartitions, Date date, String dateMask, String timeZone) throws IOException { FileSystem fs = new Path(EXTERNAL_TABLE_LOCATION).getFileSystem(new Configuration()); DateFormat dateFormat = new SimpleDateFormat(dateMask); dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); String startDate = dateFormat.format(date); Collections.sort(candidatePartitions); for (String candidatePartition : candidatePartitions) { final String path = EXTERNAL_TABLE_LOCATION + "ds=" + candidatePartition + "/region=in"; if (candidatePartition.compareTo(startDate) < 0 && fs.exists(new Path(path))) { Assert.fail("Expecting " + path + " to be deleted"); }//w w w.j ava 2s . c om } }
From source file:org.callimachusproject.behaviours.AuthenticationManagerSupport.java
public HttpResponse openIDProvider(String parameters) throws ParseException, OpenRDFException, IOException, GeneralSecurityException { Map<String, String> map = keyByName(parameters); String mode = map.get("openid.mode"); if ("associate".equals(mode)) { String body = "ns=http://specs.openid.net/auth/2.0&error=use+direct+verification&error_code=unsupported-type"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 400, "Unsupported"); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(body)); return resp; } else if ("checkid_setup".equals(mode)) { String self = this.getResource().stringValue(); String return_to = self + "?checkid&" + parameters; if (!map.containsKey("openid.return_to")) { return_to = "/"; }// www. ja v a 2s . c o m String location = self + "?login&return_to=" + encode(return_to); BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 303, "See Other"); resp.setHeader("Location", location); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(location)); return resp; } else if ("checkid_immediate".equals(mode)) { String self = this.getResource().stringValue(); String location = self + "?checkid&" + parameters; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 303, "See Other"); resp.setHeader("Location", location); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(location)); return resp; } else if ("check_authentication".equals(mode)) { String user_fullname = map.get("openid.ax.value.fullname"); String user_email = map.get("openid.ax.value.email"); String user_uri = map.get("openid.identity"); String response_nonce = map.get("openid.response_nonce"); String time = response_nonce.substring(0, response_nonce.indexOf('Z') + 1); String self = this.getResource().stringValue(); StringBuilder hash = new StringBuilder(user_uri); if (user_fullname != null && user_email != null) { hash.append(':').append(user_fullname).append(':').append(user_email); } String nonce = time + hash(hash.toString(), "MD5"); StringBuilder sig = new StringBuilder(); sig.append("openid.op_endpoint=").append(encode(self)); sig.append("&openid.identity=").append(encode(user_uri)); sig.append("&openid.claimed_id=").append(encode(user_uri)); sig.append("&openid.return_to=").append(encode(map.get("openid.return_to"))); sig.append("&openid.response_nonce=").append(encode(nonce)); Date now = new Date(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); Date then = df.parse(time); if (!nonce.equals(response_nonce)) { String body = "ns:http://specs.openid.net/auth/2.0\nis_valid:false"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 400, "Bad openid.response_nonce"); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(body)); return resp; } else if (!sig(sig.toString()).equals(map.get("openid.sig"))) { String body = "ns:http://specs.openid.net/auth/2.0\nis_valid:false"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 400, "Bad openid.sig"); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(body)); return resp; } else if (then.getTime() + MAX_NONCE_AGE < now.getTime()) { String body = "ns:http://specs.openid.net/auth/2.0\nis_valid:false"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 400, "Request Has Expired"); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(body)); return resp; } else { String body = "ns:http://specs.openid.net/auth/2.0\nis_valid:true"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); resp.setHeader("Content-Type", "text/plain"); resp.setHeader("Cache-Control", "no-store"); resp.setEntity(new StringEntity(body)); return resp; } } else { String location = this.getResource().stringValue() + "?view"; BasicHttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 303, "See Other"); resp.setHeader("Location", location); resp.setHeader("Content-Type", "text/plain"); resp.setEntity(new StringEntity(location)); return resp; } }