List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:pl.bcichecki.rms.client.android.dialogs.DeviceDetailsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (device == null) { throw new IllegalStateException("Device has not been set!"); }//from w ww. j a va 2 s .c o m context = getActivity(); eventsRestClient = new EventsRestClient(getActivity(), UserProfileHolder.getUsername(), UserProfileHolder.getPassword(), SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(getString(R.string.dialog_device_details_title, device.getName())); dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_device_details, null)); dialogBuilder.setNeutralButton(R.string.dialog_device_details_btn_show_reservations, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Date now = new Date(); final Date from = DateUtils.round(DateUtils.addDays(now, DAYS_BACK - 1), Calendar.DAY_OF_MONTH); final Date till = DateUtils.round(DateUtils.addDays(now, DAYS_AHEAD + 1), Calendar.DAY_OF_MONTH); final FragmentManager fragmentManager = getFragmentManager(); Log.d(getTag(), "Retrieving device's events for " + device); eventsRestClient.getDevicesEvents(device, from, till, new GsonHttpResponseHandler<List<Event>>(new TypeToken<List<Event>>() { }.getType(), true) { @Override public void onFailure(Throwable error, String content) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " failed. [error=" + error + ", content=" + content + "]"); if (error instanceof HttpResponseException) { if (((HttpResponseException) error) .getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { AppUtils.showCenteredToast(context, R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG); } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } @Override public void onFinish() { Log.d(getTag(), "Retrieving device's events finished."); } @Override public void onStart() { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " started."); } @Override public void onSuccess(int statusCode, List<Event> events) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " successful. Retrieved " + events.size() + " objects."); DeviceReservationsDialog deviceReservationsDialog = new DeviceReservationsDialog(); deviceReservationsDialog.setDevice(device); deviceReservationsDialog.setEvents(events); deviceReservationsDialog.show(fragmentManager, getTag()); } }); } }); dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do... } }); AlertDialog dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { TextView nameTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_name_text); nameTextView.setText(device.getName()); TextView descriptionTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_description_text); descriptionTextView.setText(device.getName()); } }); return dialog; }
From source file:io.dockstore.client.cli.nested.WorkflowClient.java
@Override public void handleInfo(String entryPath) { try {/*from w w w. ja v a 2s.c o m*/ Workflow workflow = workflowsApi.getPublishedWorkflowByPath(entryPath); if (workflow == null || !workflow.getIsPublished()) { errorMessage("This workflow is not published.", Client.COMMAND_ERROR); } else { Date dateUploaded = workflow.getLastUpdated(); String description = workflow.getDescription(); if (description == null) { description = ""; } String author = workflow.getAuthor(); if (author == null) { author = ""; } String date = ""; if (dateUploaded != null) { date = dateUploaded.toString(); } out(workflow.getPath()); out(""); out("DESCRIPTION:"); out(description); out("AUTHOR:"); out(author); out("DATE UPLOADED:"); out(date); out("WORKFLOW VERSIONS"); List<WorkflowVersion> workflowVersions = workflow.getWorkflowVersions(); int workflowVersionsSize = workflowVersions.size(); StringBuilder builder = new StringBuilder(); if (workflowVersionsSize > 0) { builder.append(workflowVersions.get(0).getName()); for (int i = 1; i < workflowVersionsSize; i++) { builder.append(", ").append(workflowVersions.get(i).getName()); } } out(builder.toString()); out("GIT REPO:"); out(workflow.getGitUrl()); } } catch (ApiException ex) { exceptionMessage(ex, "Could not find workflow", Client.API_ERROR); } }
From source file:com.cloud.network.security.NetworkGroupManagerImpl.java
private void cleanupUnfinishedWork() { Date before = new Date(System.currentTimeMillis() - 30 * 1000l); List<NetworkGroupWorkVO> unfinished = _workDao.findUnfinishedWork(before); if (unfinished.size() > 0) { s_logger.info("Network Group Work cleanup found " + unfinished.size() + " unfinished work items older than " + before.toString()); Set<Long> affectedVms = new HashSet<Long>(); for (NetworkGroupWorkVO work : unfinished) { affectedVms.add(work.getInstanceId()); }//from w w w. j a va2 s . co m scheduleRulesetUpdateToHosts(affectedVms, false, null); } else { s_logger.debug( "Network Group Work cleanup found no unfinished work items older than " + before.toString()); } }
From source file:pl.bcichecki.rms.client.android.fragments.EventsListFragment.java
private void downloadArchivedData() { if (!showArchivedEvents) { return;// w w w. j a v a2 s . c o m } Log.d(TAG, "Downloading events list..."); if (!AppUtils.checkInternetConnection(getActivity())) { Log.d(TAG, "There is NO network connected!"); return; } final Date now = new Date(); final Date from = DateUtils.round(DateUtils.addDays(now, DAYS_BACK - 1), Calendar.DAY_OF_MONTH); final Date till = DateUtils.round(DateUtils.addDays(now, DAYS_AHEAD + 1), Calendar.DAY_OF_MONTH); eventsRestClient.getAllArchivedEvents(from, till, new GsonHttpResponseHandler<List<Event>>(new TypeToken<List<Event>>() { }.getType(), true) { @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Retrieving archived events from " + from.toString() + " till " + till.toString() + " failed. [error=" + error + ", content=" + content + "]"); if (error instanceof HttpResponseException) { if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { AppUtils.showCenteredToast(getActivity(), R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG); } else { AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } else { AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } @Override public void onFinish() { eventsListAdapter.refresh(); hideLoadingMessage(); Log.d(TAG, "Retrieving archived events finished."); } @Override public void onStart() { Log.d(TAG, "Retrieving archived events from " + from.toString() + " till " + till.toString() + " started."); showLoadingMessage(); } @Override public void onSuccess(int statusCode, List<Event> object) { Log.d(TAG, "Retrieving archived events from " + from.toString() + " till " + till.toString() + " successful. Retrieved " + object.size() + " objects."); events.addAll(object); } }); }
From source file:edu.hawaii.soest.kilonalu.utilities.FileSource.java
/** * A method that executes the reading of data from the data file to the RBNB * server after all configuration of settings, connections to hosts, and * thread initiatizing occurs. This method contains the detailed code for * reading the data and interpreting the data files. *//*from w w w . j av a 2s .co m*/ protected boolean execute() { logger.debug("FileSource.execute() called."); boolean failed = true; // indicates overall success of execute() // do not execute the stream if there is no connection if (!isConnected()) return false; try { // open the data file for monitoring FileReader reader = new FileReader(new File(getFileName())); this.fileReader = new BufferedReader(reader); // add channels of data that will be pushed to the server. // Each sample will be sent to the Data Turbine as an rbnb frame. int channelIndex = 0; ChannelMap rbnbChannelMap = new ChannelMap(); // used to insert channel data ChannelMap registerChannelMap = new ChannelMap(); // used to register channels // add the DecimalASCIISampleData channel to the channelMap channelIndex = registerChannelMap.Add(getRBNBChannelName()); registerChannelMap.PutUserInfo(channelIndex, "units=none"); // and register the RBNB channels getSource().Register(registerChannelMap); registerChannelMap.Clear(); // on execute(), query the DT to find the timestamp of the last sample inserted // and be sure the following inserts are after that date ChannelMap requestMap = new ChannelMap(); int entryIndex = requestMap.Add(getRBNBClientName() + "/" + getRBNBChannelName()); logger.debug("Request Map: " + requestMap.toString()); Sink sink = new Sink(); sink.OpenRBNBConnection(getServer(), "lastEntrySink"); sink.Request(requestMap, 0., 1., "newest"); ChannelMap responseMap = sink.Fetch(5000); // get data within 5 seconds // initialize the last sample date Date initialDate = new Date(); long lastSampleTimeAsSecondsSinceEpoch = initialDate.getTime() / 1000L; logger.debug("Initialized the last sample date to: " + initialDate.toString()); logger.debug("The last sample date as a long is: " + lastSampleTimeAsSecondsSinceEpoch); if (responseMap.NumberOfChannels() == 0) { // set the last sample time to 0 since there are no channels yet lastSampleTimeAsSecondsSinceEpoch = 0L; logger.debug("Resetting the last sample date to the epoch: " + (new Date(lastSampleTimeAsSecondsSinceEpoch * 1000L)).toString()); } else if (responseMap.NumberOfChannels() > 0) { lastSampleTimeAsSecondsSinceEpoch = new Double(responseMap.GetTimeStart(entryIndex)).longValue(); logger.debug("There are existing channels. Last sample time: " + (new Date(lastSampleTimeAsSecondsSinceEpoch * 1000L)).toString()); } sink.CloseRBNBConnection(); // poll the data file for new lines of data and insert them into the RBNB while (true) { String line = fileReader.readLine(); if (line == null) { this.streamingThread.sleep(POLL_INTERVAL); } else { // test the line for the expected data pattern Matcher matcher = this.dataPattern.matcher(line); // if the line matches the data pattern, insert it into the DataTurbine if (matcher.matches()) { logger.debug("This line matches the data line pattern: " + line); Date sampleDate = getSampleDate(line); if (this.dateFormats == null || this.dateFields == null) { logger.warn("Using the default datetime format and field for sample data. " + "Use the -f and -d options to explicitly set date time fields."); } logger.debug("Sample date is: " + sampleDate.toString()); // convert the sample date to seconds since the epoch long sampleTimeAsSecondsSinceEpoch = (sampleDate.getTime() / 1000L); // only insert samples newer than the last sample seen at startup // and that are not in the future (> 1 hour since the CTD clock // may have drifted) Calendar currentCal = Calendar.getInstance(); this.tz = TimeZone.getTimeZone(this.timezone); currentCal.setTimeZone(this.tz); currentCal.add(Calendar.HOUR, 1); Date currentDate = currentCal.getTime(); if (lastSampleTimeAsSecondsSinceEpoch < sampleTimeAsSecondsSinceEpoch && sampleTimeAsSecondsSinceEpoch < currentDate.getTime() / 1000L) { // add the sample timestamp to the rbnb channel map //registerChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d); rbnbChannelMap.PutTime((double) sampleTimeAsSecondsSinceEpoch, 0d); // then add the data line to the channel map channelIndex = rbnbChannelMap.Add(getRBNBChannelName()); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, line + "\r\n"); // be sure we are connected int numberOfChannelsFlushed = 0; try { //insert into the DataTurbine numberOfChannelsFlushed = getSource().Flush(rbnbChannelMap, true); // in the event we just lost the network, sleep, try again while (numberOfChannelsFlushed < 1) { logger.debug("No channels flushed, trying again in 10 seconds."); Thread.sleep(10000L); numberOfChannelsFlushed = getSource().Flush(rbnbChannelMap, true); } } catch (SAPIException sapie) { // reconnect if an exception is thrown on Flush() logger.debug("Error while flushing the source: " + sapie.getMessage()); logger.debug("Disconnecting from the DataTurbine."); disconnect(); logger.debug("Connecting to the DataTurbine."); connect(); getSource().Flush(rbnbChannelMap); // in the event we just lost the network, sleep, try again while (numberOfChannelsFlushed < 1) { logger.debug("No channels flushed, trying again in 10 seconds."); Thread.sleep(10000L); numberOfChannelsFlushed = getSource().Flush(rbnbChannelMap, true); } } // reset the last sample time to the sample just inserted lastSampleTimeAsSecondsSinceEpoch = sampleTimeAsSecondsSinceEpoch; logger.debug("Last sample time is now: " + (new Date(lastSampleTimeAsSecondsSinceEpoch * 1000L).toString())); logger.info(getRBNBClientName() + " Sample sent to the DataTurbine: " + line.trim()); rbnbChannelMap.Clear(); } else { logger.info("The current line is earlier than the last entry " + "in the Data Turbine or is a date in the future. " + "Skipping it. The line was: " + line); } } else { logger.info("The current line doesn't match an expected " + "data line pattern. Skipping it. The line was: " + line); } } // end if() } // end while } catch (ParseException pe) { logger.info( "There was a problem parsing the sample date string. " + "The message was: " + pe.getMessage()); try { this.fileReader.close(); } catch (IOException ioe2) { logger.info( "There was a problem closing the data file. The " + "message was: " + ioe2.getMessage()); } failed = true; return !failed; } catch (SAPIException sapie) { logger.info("There was a problem communicating with the DataTurbine. " + "The message was: " + sapie.getMessage()); try { this.fileReader.close(); } catch (IOException ioe2) { logger.info( "There was a problem closing the data file. The " + "message was: " + ioe2.getMessage()); } failed = true; return !failed; } catch (InterruptedException ie) { logger.info( "There was a problem while polling the data file. The " + "message was: " + ie.getMessage()); try { this.fileReader.close(); } catch (IOException ioe2) { logger.info( "There was a problem closing the data file. The " + "message was: " + ioe2.getMessage()); } failed = true; return !failed; } catch (IOException ioe) { logger.info("There was a problem opening the data file. " + "The message was: " + ioe.getMessage()); failed = true; return !failed; } }
From source file:io.lqd.sdk.Liquid.java
private void destroySession(Date closeDate) { if ((mCurrentUser != null) && (mCurrentSession != null) && mCurrentSession.getEndDate() == null) { LQLog.infoVerbose("Close Session: " + closeDate.toString()); mCurrentSession.setEndDate(closeDate); track("_endSession", null, closeDate); }/* www. ja v a 2 s .c om*/ }
From source file:ch.ralscha.extdirectspring.provider.RemoteProviderStoreRead.java
@ExtDirectMethod(value = ExtDirectMethodType.STORE_READ) public ExtDirectStoreResult<Row> method8(@DateTimeFormat(iso = ISO.DATE_TIME) Date endDate, final HttpServletRequest servletRequest, ExtDirectStoreReadRequest request) { assertThat(endDate).isNotNull();/*from w w w . j a va 2s .co m*/ assertThat(servletRequest).isNotNull(); return createExtDirectStoreResult(request, ":" + endDate.toString() + ";" + (servletRequest != null)); }
From source file:db_classes.DBManager.java
/** * /*from w w w .j a v a 2s . c om*/ * @param user nome dell' utente che commenta * @param restaurant ristorante che riceve il commento * @param title titolo della recensione * @param description la recensine vera e propria * @param img l' immagine allegata * @param rating le stelline * @throws SQLException */ public void addReviewPerRestaurant(int user, String restaurant, String title, String description, String img, int rating) throws SQLException { String query = "INSERT INTO reviews (name,description,date_creation,id_restaurant,id_creator,id_photo,global_value)" + "VALUES('?','?','?','?','?','?','?')"; Date date = new Date(); System.out.println("nome ristorante: " + restaurant + "" + " utente: " + user + " descrizione: " + description + " data: " + date); String queryPerID = "SELECT id FROM restaurants WHERE name= ?"; PreparedStatement psId = con.prepareStatement(queryPerID); psId.setString(1, restaurant); ResultSet rs = psId.executeQuery(); int resId = Integer.parseInt(rs.getString(1)); rs.close(); PreparedStatement psReview = con.prepareStatement(query); psReview.setString(1, restaurant); psReview.setString(2, description); psReview.setString(3, date.toString()); psReview.setInt(4, resId); psReview.setInt(5, user); psReview.setString(6, img); psReview.setInt(rating, rating); ResultSet reSet = psReview.executeQuery(); }
From source file:org.awknet.commons.model.business.UserBOImpl.java
/** * Create a code based in:<br/>/* w ww. j a va 2 s. c o m*/ * retrieveCode = id_user + login + email + IP address + actual date<br/> * If the code is already in DB, will throw a exception (the code must be * unique!)! * * @param userID * @return a retrieve code to password * @throws UserException */ public String generateCodeToRetrievePassword(Long userID, String ip) throws UserException, RetrieveCodeException { String retrieveCode; Date dateRequestedNewPassword = Calendar.getInstance().getTime(); RetrievePasswordLog rpLog = new RetrievePasswordLog(); if (ip.equals("") || ip == null) throw new RetrieveCodeException(RetrieveCodeExceptionType.IP); if (userID == null) throw new UserException(UserExceptionType.ID); User entity = daoFactory.getUserDao().load(userID); if (entity == null) throw new UserException(UserExceptionType.ID); retrieveCode = Encryption.encrypt( entity.getID() + entity.getLogin() + entity.getEmail() + ip + dateRequestedNewPassword.toString()); if (daoFactory.getRetrievePasswordLogDao().findRetrieveCode(retrieveCode) != null) throw new RetrieveCodeException(RetrieveCodeExceptionType.RETRIEVE_CODE); rpLog.setRetrieveCode(retrieveCode); rpLog.setUserId(userID); rpLog.setIp(ip); rpLog.setRequest(dateRequestedNewPassword); rpLog.setUpdated(false); try { daoFactory.beginTransaction(); LOG.info("[GENERATE CODE] " + daoFactory.getRetrievePasswordLogDao().updateRetrieveCodeUnused(userID) + " retrieveCode was reseted for user: " + userID); daoFactory.getRetrievePasswordLogDao().save(rpLog); daoFactory.commit(); } catch (ConstraintViolationException e) { LOG.error("[RETRIEVE PASSWORD] code not saved in DB.", e); return null; } catch (Exception e) { LOG.error("[RETRIEVE PASSWORD] generic error in DB.", e); return null; } return retrieveCode; }
From source file:org.opendap.d1.DAPResourceHandler.java
/** * This function is called from the REST API servlet and handles each request * //from w w w. j av a 2 s .c om * @param httpVerb (GET, HEAD, POST) */ public void handle(byte httpVerb) { try { // Set the Session member; null indicates no session info // FIXME getSession(); try { // get the resource String resource = request.getPathInfo(); log.debug("handling verb {} request with resource '{}'", httpVerb, resource); // In the web.xml for the DAPRestServlet, I set the url pattern // like this: <url-pattern>/d1/mn/*</url-pattern> which means // that the leading '/d1/mn/' is removed by the servlet container. // Since this servlet implements only the 'v1' API, I've hardcoded // that value here. It could be read from the config file using // the org.opendap.d1.mnCore.serviceVersion and mnRead... // properties. jhrg 5/20/14 resource = parseTrailing(resource, API_VERSION); log.debug("processed resource: '" + resource + "'"); // default to node info if (resource == null || resource.equals("")) { resource = RESOURCE_NODE; } // get the rest of the path info String extra = null; boolean status = false; if (resource.startsWith(RESOURCE_NODE)) { log.debug("Using resource '" + RESOURCE_NODE + "'"); if (httpVerb == GET) { // node (aka getCapabilities) response. The method uses // the output stream to serialize the result and throws // an // exception if there's a problem. sendNodeResponse(); status = true; } } else if (resource.startsWith(RESOURCE_META)) { log.debug("Using resource '" + RESOURCE_META + "'"); if (httpVerb == GET) { // after the command extra = parseTrailing(resource, RESOURCE_META); // NB: When Tomcat is configured to allow URL encoded paths into the servlets, // it does the decoding before making the doGet(), ..., calls. // However, here's code to decode the PID, if it's ever needed. jhrg 6/13/14 // logDAP.debug("PID before decoding: " + parseTrailing(resource, RESOURCE_META)); // extra = new URI(parseTrailing(resource, RESOURCE_META)).getPath(); // logDAP.debug("PID after decoding: " + extra); sendSysmetaResponse(extra); status = true; } } else if (resource.startsWith(RESOURCE_OBJECTS)) { // This is the get() call which returns SDOs and SMOs // or the describe() call for the same depending on the // HTTP verb (GET or HEAD) log.debug("Using resource '" + RESOURCE_OBJECTS + "'"); // 'extra' is text that follows the command in the URL's path. extra = parseTrailing(resource, RESOURCE_OBJECTS); log.debug("objectId: " + extra); log.debug("verb:" + httpVerb); if (httpVerb == GET) { if (extra == null || extra.isEmpty()) { Hashtable<String, String[]> params = new Hashtable<String, String[]>(); initParams(params); sendListObjects(params); } else { // In the line that follows, I cannot get Event.READ to work but I know // that simple strings work. logDb.addEntry(extra, request.getRemoteAddr(), request.getHeader("user-agent"), Constants.SUBJECT_PUBLIC, "read"); sendObject(extra); } status = true; } else if (httpVerb == HEAD) { sendDescribeObject(extra); status = true; } } else if (resource.startsWith(RESOURCE_LOG)) { log.debug("Using resource '" + RESOURCE_LOG + "'"); // handle log events if (httpVerb == GET) { Hashtable<String, String[]> params = new Hashtable<String, String[]>(); initParams(params); sendLogEntries(params); status = true; } } else if (resource.startsWith(RESOURCE_CHECKSUM)) { log.debug("Using resource '" + RESOURCE_CHECKSUM + "'"); // handle checksum requests if (httpVerb == GET) { // 'extra' is text that follows the command in the URL's path. extra = parseTrailing(resource, RESOURCE_CHECKSUM); String algorithm = "SHA-1"; sendChecksum(extra, algorithm); status = true; } } else if (resource.startsWith(RESOURCE_REPLICA)) { log.debug("Using resource '" + RESOURCE_REPLICA + "'"); // handle replica requests if (httpVerb == GET) { extra = parseTrailing(resource, RESOURCE_REPLICA); sendReplica(extra); status = true; } } else if (resource.startsWith(RESOURCE_MONITOR)) { log.debug("Processing resource '" + RESOURCE_MONITOR + "'"); // there are various parts to monitoring if (httpVerb == GET) { extra = parseTrailing(resource, RESOURCE_MONITOR); // ping if (extra.toLowerCase().equals("ping")) { log.debug("processing ping request"); Date result = DAPMNodeService.getInstance(request, db, logDb).ping(); if (result != null) { log.debug("processing ping result: " + result.toString()); response.setDateHeader("Date", result.getTime()); response.setStatus(200); response.getWriter().println(result.toString()); } else { log.debug("processing ping result: null"); response.setStatus(400); response.getWriter().println("No response from the underlying DAP server."); } status = true; } } } else if (resource.startsWith(RESOURCE_ERROR)) { log.debug("Processing resource '{}'", RESOURCE_ERROR); SynchronizationFailed sf = collectSynchronizationFailed(); DAPMNodeService.getInstance(request, db, logDb).synchronizationFailed(sf); status = true; } else { throw new InvalidRequest("0000", "No resource matched for " + resource); } if (!status) { throw new ServiceFailure("0000", "Unknown error while processing resource: " + resource); } } catch (BaseException be) { // report Exceptions as clearly as possible OutputStream out = null; try { out = response.getOutputStream(); } catch (IOException e) { log.error("Could not get output stream from response", e); } serializeException(be, out); } catch (Exception e) { // report Exceptions as clearly and generically as possible log.error(e.getClass() + ": " + e.getMessage(), e); OutputStream out = null; try { out = response.getOutputStream(); } catch (IOException ioe) { log.error("Could not get output stream from response", ioe); } ServiceFailure se = new ServiceFailure("2162", e.getMessage()); serializeException(se, out); } } catch (Exception e) { response.setStatus(400); printError("Incorrect resource!", response); log.error(e.getClass() + ": " + e.getMessage(), e); } }