List of usage examples for java.text DateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:org.squale.squalix.core.AbstractTask.java
/** * Cre les erreurs et les persiste dans la base */// ww w . jav a 2 s . com private void createErrors() { // la liste a t initialise 0 lments if (mErrors.size() > 0) { boolean hasFatalError = false; Iterator it = mErrors.iterator(); while (it.hasNext()) { ErrorBO error = (ErrorBO) it.next(); // le seul champ remplir if (null == error.getTaskName()) { error.setTaskName(mName); } // si la tache n'est pas failed(peut arriver si la tache n'a pas lev d'exception) // et qu'une erreur est fatale on met le status Failed // on met le status de la tache au status maximum des erreurs if (mStatus != FAILED && error.getLevel() == ErrorBO.CRITICITY_FATAL) { mStatus = FAILED; hasFatalError = true; } if (!it.hasNext() && mStatus == FAILED) { // If task has failed, we set the last error in fatal criticity // if task doesn't already contain one. if (!hasFatalError) { error.setLevel(ErrorBO.CRITICITY_FATAL); } // Dans le cas d'une erreur fatale, on prvient les admins // que la tache a chou Date current = Calendar.getInstance().getTime(); DateFormat formatter = new SimpleDateFormat("d MMM yyyy HH:mm:ss 'GMT'", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); String hour = formatter.format(current); String[] infos = new String[] { mName, mApplication.getName(), mApplication.getServeurBO().getName(), mProject.getName(), "" + mAudit.getId(), hour }; String object = Messages.getString("mail.sender.squalix.task", new String[] { mApplication.getName() }) + Messages.getString("mail.task.failed.object", infos); MessageMailManager mail = new MessageMailManager(); mail.addContent("mail.header", null); mail.addContent("mail.task.failed.content", infos); String content = mail.getContent(); String dest = SqualeCommonConstants.ONLY_ADMINS; IMailerProvider mailer = MailerHelper.getMailerProvider(); SqualeCommonUtils.notifyByEmail(mailer, null, dest, null, object, content, false); } // Pas de conversion InitialMessage -> Message try { // On attribue les bonnes valeurs aux erreurs error.setProject(mProject); error.setAudit(mAudit); // enregistrement en base ErrorDAOImpl.getInstance().create(mSession, error); mSession.closeSession(); } catch (JrafDaoException e) { LOGGER.error(e, e); } } } }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
private void setupBuildSection() { buildNameView.setText(BuildConfig.VERSION_NAME); buildCodeView.setText(String.valueOf(BuildConfig.VERSION_CODE)); buildShaView.setText(BuildConfig.GIT_SHA); try {/* ww w .ja v a 2 s.c o m*/ // Parse ISO8601-format time into local time. DateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); inFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date buildTime = inFormat.parse(BuildConfig.BUILD_TIME); buildDateView.setText(DATE_DISPLAY_FORMAT.format(buildTime)); } catch (ParseException e) { throw new RuntimeException("Unable to decode build time: " + BuildConfig.BUILD_TIME, e); } }
From source file:org.b3log.solo.api.metaweblog.MetaWeblogAPI.java
/** * Parses the specified method call for an article. * //from w w w . j ava2 s .co m * @param methodCall the specified method call * @return article * @throws Exception exception */ private JSONObject parsetPost(final JSONObject methodCall) throws Exception { final JSONObject ret = new JSONObject(); final JSONArray params = methodCall.getJSONObject("params").getJSONArray("param"); final JSONObject post = params.getJSONObject(INDEX_POST).getJSONObject("value").getJSONObject("struct"); final JSONArray members = post.getJSONArray("member"); for (int i = 0; i < members.length(); i++) { final JSONObject member = members.getJSONObject(i); final String name = member.getString("name"); if ("dateCreated".equals(name)) { final JSONObject preference = preferenceQueryService.getPreference(); final String dateString = member.getJSONObject("value").getString("dateTime.iso8601"); Date date = null; try { date = (Date) DateFormatUtils.ISO_DATETIME_FORMAT.parseObject(dateString); } catch (final ParseException e) { LOGGER.log(Level.WARNING, "Parses article create date failed with ISO8601, retry to parse with pattern[yyyy-MM-dd'T'HH:mm:ss]"); final String timeZoneId = preference.getString(Preference.TIME_ZONE_ID); final TimeZone timeZone = TimeZone.getTimeZone(timeZoneId); final DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); format.setTimeZone(timeZone); date = format.parse(dateString); } ret.put(Article.ARTICLE_CREATE_DATE, date); } else if ("title".equals(name)) { ret.put(Article.ARTICLE_TITLE, member.getJSONObject("value").getString("string")); } else if ("description".equals(name)) { final String content = member.getJSONObject("value").getString("string"); ret.put(Article.ARTICLE_CONTENT, content); final String plainTextContent = Jsoup.parse(content).text(); if (plainTextContent.length() > ARTICLE_ABSTRACT_LENGTH) { ret.put(Article.ARTICLE_ABSTRACT, plainTextContent.substring(0, ARTICLE_ABSTRACT_LENGTH)); } else { ret.put(Article.ARTICLE_ABSTRACT, plainTextContent); } } else if ("categories".equals(name)) { final StringBuilder tagBuilder = new StringBuilder(); final JSONObject data = member.getJSONObject("value").getJSONObject("array").getJSONObject("data"); if (0 == data.length()) { throw new Exception("At least one Tag"); } final Object value = data.get("value"); if (value instanceof JSONArray) { final JSONArray tags = (JSONArray) value; for (int j = 0; j < tags.length(); j++) { final String tagTitle = tags.getJSONObject(j).getString("string"); tagBuilder.append(tagTitle); if (j < tags.length() - 1) { tagBuilder.append(","); } } } else { final JSONObject tag = (JSONObject) value; tagBuilder.append(tag.getString("string")); } ret.put(Article.ARTICLE_TAGS_REF, tagBuilder.toString()); } } final boolean publish = 1 == params.getJSONObject(INDEX_PUBLISH).getJSONObject("value").getInt("boolean") ? true : false; ret.put(Article.ARTICLE_IS_PUBLISHED, publish); ret.put(Article.ARTICLE_COMMENTABLE, true); ret.put(Article.ARTICLE_VIEW_PWD, ""); return ret; }
From source file:com.clustercontrol.custom.factory.RunCustom.java
/** * ????<br/>//from ww w .j ava2 s .c o m * @throws HinemosUnknown ?????? * @throws MonitorNotFound ?????? * @throws CustomInvalid ?????? */ @Override public void monitor() throws HinemosUnknown, MonitorNotFound, CustomInvalid { // Local Variables MonitorInfo monitor = null; int priority = PriorityConstant.TYPE_UNKNOWN; String facilityPath = ""; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(HinemosTime.getTimeZone()); String executeDate = ""; String exitDate = ""; String collectDate = ""; String msg = ""; String msgOrig = ""; double value = -1; boolean isMonitorJob = result.getRunInstructionInfo() != null; // MAIN try { monitor = new MonitorSettingControllerBean().getMonitor(result.getMonitorId()); facilityPath = new RepositoryControllerBean().getFacilityPath(result.getFacilityId(), null); executeDate = dateFormat.format(result.getExecuteDate()); exitDate = dateFormat.format(result.getExitDate()); collectDate = dateFormat.format(result.getCollectDate()); if (result.getTimeout() || result.getStdout() == null || "".equals(result.getStdout()) || result.getResults() == null) { if (m_log.isDebugEnabled()) { m_log.debug("command monitoring : timeout or no stdout [" + result + "]"); } // if command execution failed (timeout or no stdout) if (isMonitorJob || monitor.getMonitorFlg()) { msg = "FAILURE : command execution failed (timeout, no stdout or not unexecutable command)..."; msgOrig = "FAILURE : command execution failed (timeout, no stdout or unexecutable command)...\n\n" + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n" + "[STDERR]\n" + result.getStderr() + "\n"; // if (!isMonitorJob) { notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath, null, msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); } else { // this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue( result.getRunInstructionInfo(), PriorityConstant.TYPE_UNKNOWN))); } } } else { List<Sample> sampleList = new ArrayList<Sample>(); // if command stdout was returned for (String key : result.getResults().keySet()) { if (m_log.isDebugEnabled()) { m_log.debug("command monitoring : judgement values [" + result + ", key = " + key + "]"); } if (isMonitorJob || monitor.getMonitorFlg()) { // monitor each value // if (monitor.getCustomCheckInfo().getConvertFlg() == ConvertValueConstant.TYPE_NO) { priority = judgePriority((Double) result.getResults().get(key)); msg = "VALUE : " + key + "=" + result.getResults().get(key); msgOrig = "VALUE : " + key + "=" + result.getResults().get(key) + "\n\n" + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n" + result.getStderr() + "\n"; if (!isMonitorJob) { // notify(priority, monitor, result.getFacilityId(), facilityPath, key, msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); } else { // this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue(result.getRunInstructionInfo(), priority))); } } else if (monitor.getCustomCheckInfo() .getConvertFlg() == ConvertValueConstant.TYPE_DELTA) { // ????????? // ?? MonitorCustomValue valueEntity = null; Double prevValue = 0d; Long prevDate = 0l; // cache?? if (!isMonitorJob) { // valueEntity = MonitorCustomCache.getMonitorCustomValue(monitor.getMonitorId(), monitor.getFacilityId()); prevValue = (Double) valueEntity.getValue(); // ??? if (valueEntity.getGetDate() != null) { prevDate = valueEntity.getGetDate(); } } else { // valueEntity = (MonitorCustomValue) MonitorJobWorker .getPrevMonitorValue(result.getRunInstructionInfo()); if (valueEntity != null) { // ???? prevValue = (Double) valueEntity.getValue(); prevDate = valueEntity.getGetDate(); } else { valueEntity = new MonitorCustomValue(new MonitorCustomValuePK( monitor.getMonitorId(), monitor.getFacilityId())); } } // ???? valueEntity.setValue(result.getResults().get(key)); valueEntity.setGetDate(result.getCollectDate()); if (!isMonitorJob) { // ???ID????? MonitorCustomCache.update(monitor.getMonitorId(), monitor.getFacilityId(), valueEntity); int m_validSecond = HinemosPropertyUtil .getHinemosPropertyNum("monitor.custom.valid.second", Long.valueOf(15)) .intValue(); // ??????????? int tolerance = (monitor.getRunInterval() + m_validSecond) * 1000; if (prevDate > result.getCollectDate() - tolerance) { if (prevValue == null) { m_log.debug("collect() : prevValue is null"); notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath, null, msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); return; } value = (Double) result.getResults().get(key) - prevValue; } else { if (prevDate != 0l) { DateFormat df = DateFormat.getDateTimeInstance(); df.setTimeZone(HinemosTime.getTimeZone()); String[] args = { df.format(new Date(prevDate)) }; msg = MessageConstant.MESSAGE_TOO_OLD_TO_CALCULATE.getMessage(args); notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath, null, msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); return; } else { // ?????????? return; } } priority = judgePriority(value); msg = "DIFF VALUE : " + key + "=" + value; msgOrig = "DIFF VALUE : " + key + "=" + value + "\n" + "CURRENT VALUE : " + key + "=" + result.getResults().get(key) + "\n" + "PREVIOUS VALUE : " + key + "=" + prevValue + "\n\n" + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n" + result.getStderr() + "\n"; notify(priority, monitor, result.getFacilityId(), facilityPath, key, msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); } else { if (prevDate != 0l) { // ???? value = (Double) result.getResults().get(key) - prevValue; priority = judgePriority(value); msg = "DIFF VALUE : " + key + "=" + value; msgOrig = "DIFF VALUE : " + key + "=" + value + "\n" + "CURRENT VALUE : " + key + "=" + result.getResults().get(key) + "\n" + "PREVIOUS VALUE : " + key + "=" + prevValue + "\n\n" + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n" + result.getStderr() + "\n"; // this.monitorJobEndNodeList.add(new MonitorJobEndNode( result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue(result.getRunInstructionInfo(), priority))); } else { // ?????? MonitorJobWorker.addPrevMonitorValue(result.getRunInstructionInfo(), valueEntity); } } } } if (!isMonitorJob && monitor.getCollectorFlg()) { // collector each value Sample sample = new Sample( result.getCollectDate() == null ? null : new Date(result.getCollectDate()), monitor.getMonitorId()); // if (monitor.getCustomCheckInfo().getConvertFlg() == ConvertValueConstant.TYPE_NO) { sample.set(result.getFacilityId(), monitor.getItemName(), (Double) result.getResults().get(key), CollectedDataErrorTypeConstant.NOT_ERROR, key); } else if (monitor.getCustomCheckInfo() .getConvertFlg() == ConvertValueConstant.TYPE_DELTA) { sample.set(result.getFacilityId(), monitor.getItemName(), value, CollectedDataErrorTypeConstant.NOT_ERROR, key); } sampleList.add(sample); } } if (!sampleList.isEmpty()) { CollectDataUtil.put(sampleList); } if (isMonitorJob || monitor.getMonitorFlg()) { // notify invalid lines of stdout for (Integer lineNum : result.getInvalidLines().keySet()) { if (m_log.isDebugEnabled()) { m_log.debug("command monitoring : notify invalid result [" + result + ", lineNum = " + lineNum + "]"); } msg = "FAILURE : invalid line found (not 2 column or duplicate) - (line " + lineNum + ") " + result.getInvalidLines().get(lineNum); msgOrig = "FAILURE : invalid line found (not 2 column or duplicate) - (line " + lineNum + ") " + result.getInvalidLines().get(lineNum) + "\n\n" + "COMMAND : " + result.getCommand() + "\n" + "COLLECTION DATE : " + collectDate + "\n" + "executed at " + executeDate + "\n" + "exited (or timeout) at " + exitDate + "\n" + "EXIT CODE : " + (result.getExitCode() != null ? result.getExitCode() : "timeout") + "\n\n" + "[STDOUT]\n" + result.getStdout() + "\n\n" + "[STDERR]\n" + result.getStderr() + "\n"; if (!isMonitorJob) { // notify(PriorityConstant.TYPE_UNKNOWN, monitor, result.getFacilityId(), facilityPath, lineNum.toString(), msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_N); } else { // this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_N, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue( result.getRunInstructionInfo(), PriorityConstant.TYPE_UNKNOWN))); } } } } } catch (MonitorNotFound e) { m_log.warn("unexpected internal failure occurred. [" + result + "]"); throw e; } catch (CustomInvalid e) { m_log.warn("unexpected internal failure occurred. [" + result + "]"); throw e; } catch (HinemosUnknown e) { m_log.warn("unexpected internal failure occurred. [" + result + "]"); throw e; } catch (Exception e) { m_log.warn("unexpected internal failure occurred. [" + result + "]", e); throw new HinemosUnknown("unexpected internal failure occurred. [" + result + "]", e); } }
From source file:org.codice.ddf.security.idp.server.IdpEndpointTest.java
@Test public void testShowGetLoginWithCookieAssertionAfterTimeBounds() throws CertificateEncodingException, WSSecurityException, SAXException, IOException, ParserConfigurationException { String samlRequest = authNRequestGet; HttpServletRequest request = mock(HttpServletRequest.class); Cookie cookie = mock(Cookie.class); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.add(Calendar.SECOND, -1); Date beforeNow = calendar.getTime(); DateFormat dateFormat = new SimpleDateFormat(samlConditionDateFormat); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Element assertionElement = readDocument("/saml.xml").getDocumentElement(); //Change the NotOnOrAfter Date on the SAML Assertion to be before "now" assertionElement.getElementsByTagName("saml2:Conditions").item(0).getAttributes() .getNamedItem("NotOnOrAfter").setNodeValue(dateFormat.format(beforeNow)); when(request.isSecure()).thenReturn(true); when(request.getRequestURL()).thenReturn(requestURL); when(request.getAttribute(ContextPolicy.ACTIVE_REALM)).thenReturn("*"); when(request.getCookies()).thenReturn(new Cookie[] { cookie }); when(cookie.getName()).thenReturn(IdpEndpoint.COOKIE); when(cookie.getValue()).thenReturn("2"); idpEndpoint.cookieCache.cacheSamlAssertion("2", assertionElement); assertNotNull(idpEndpoint.cookieCache.getSamlAssertion("2")); Response response = idpEndpoint.showGetLogin(samlRequest, relayState, signatureAlgorithm, signature, request);/*from w w w.ja v a 2s. c o m*/ assertThat(response.getEntity().toString(), containsString("<title>Login</title>")); assertNull(idpEndpoint.cookieCache.getSamlAssertion("2")); }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * // w ww .j a va2s . co m */ protected void fillDateFormat() { String currentFormat = AppPreferences.getRemote().get("ui.formatting.scrdateformat", null); TimeZone tz = TimeZone.getDefault(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); dateFormatter.setTimeZone(tz); String dateStr = dateFormatter.format(Calendar.getInstance().getTime()); Character ch = null; for (int i = 0; i < 10; i++) { if (!StringUtils.isNumeric(dateStr.substring(i, i + 1))) { ch = dateStr.charAt(i); break; } } if (ch != null) { boolean skip = false; Vector<String> formats = new Vector<String>(); if (ch == '/') { addFormats(formats, '/'); skip = true; } if (ch != '.') { addFormats(formats, '.'); skip = true; } if (ch != '-') { addFormats(formats, '-'); skip = true; } if (!skip) { addFormats(formats, ch); } int selectedInx = 0; int inx = 0; DefaultComboBoxModel model = (DefaultComboBoxModel) dateFieldCBX.getModel(); for (String fmt : formats) { model.addElement(fmt); if (currentFormat != null && currentFormat.equals(fmt)) { selectedInx = inx; } inx++; } dateFieldCBX.getComboBox().setSelectedIndex(selectedInx); } }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * Returns an initialized DateFormat object. * * @param dateTimeFormat optional format string * @param tz/* w w w. j av a2 s .c o m*/ * @param locale can be null if dateTimeFormat is not null * @return DateFormat object */ public static DateFormat toDateTimeFormat(String dateTimeFormat, TimeZone tz, Locale locale) { DateFormat df = null; if (dateTimeFormat == null) { df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(dateTimeFormat); } df.setTimeZone(tz); return df; }
From source file:net.wastl.webmail.xml.XMLUserData.java
private String formatDate(long date) { TimeZone tz = TimeZone.getDefault(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.DEFAULT, getPreferredLocale()); df.setTimeZone(tz); String now = df.format(new Date(date)); return now;/* ww w.ja v a 2 s. c o m*/ }
From source file:org.fhaes.fhfilereader.FHFile.java
/** * Get the sampling date of the first samples within this file. * /*from w w w . jav a 2 s . c om*/ * @return */ public String getFirstCollectionDate() { projects = tricycleReader.getProjects(); if (projects == null) return null; if (projects.length == 0) return null; TridasProject p = projects[0]; if (p.isSetObjects()) { try { Date dt = p.getObjects().get(0).getElements().get(0).getSamples().get(0).getSamplingDate() .getValue().toGregorianCalendar().getTime(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(dt); } catch (Exception e) { } } return null; }
From source file:com.krawler.spring.importFunctionality.ImportController.java
public ModelAndView getImportLog(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); boolean issuccess = false; String msg = ""; try {//from ww w. j a v a 2 s .c o m DateFormat sdf = new SimpleDateFormat(Constants.yyyyMMddHHmmss); String tzDiff = authHandler.getTimeZoneDifference(request); TimeZone zone = TimeZone.getTimeZone("GMT" + tzDiff); sdf.setTimeZone(zone); HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("start", request.getParameter("start")); requestParams.put("limit", request.getParameter("limit")); requestParams.put("startdate", sdf.parse(request.getParameter("startdate")).getTime()); requestParams.put("enddate", sdf.parse(request.getParameter("enddate")).getTime()); requestParams.put("companyid", sessionHandlerImpl.getCompanyid(request)); StringBuffer moduleid = new StringBuffer(); if ((sessionHandlerImpl.getPerms(request, ProjectFeature.leadFName) & 64) == 64) { moduleid.append("'" + Constants.MODULEID_LEAD + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.productFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_PRODUCT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.accountFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_ACCOUNT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.contactFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_CONTACT + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.targetFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_TARGET + "',"); } if ((sessionHandlerImpl.getPerms(request, ProjectFeature.opportunityFName) & 32) == 32) { moduleid.append("'" + Constants.MODULEID_OPPORTUNITY + "',"); } // fetch calibration report log entry (For sunrise client) moduleid.append("'" + Constants.MODULEID_CALIBRATION + "',"); String moduleids = moduleid.substring(0, (moduleid.length() - 1)); requestParams.put("moduleid", moduleids); KwlReturnObject result = importDao.getImportLog(requestParams); List list = result.getEntityList(); DateFormat df = authHandler.getDateFormatter(request); df.setTimeZone(zone); JSONArray jArr = new JSONArray(); Iterator itr = list.iterator(); while (itr.hasNext()) { ImportLog ilog = (ImportLog) itr.next(); JSONObject jtemp = new JSONObject(); jtemp.put("id", ilog.getId()); jtemp.put("filename", ilog.getFileName()); jtemp.put("storename", ilog.getStorageName()); jtemp.put("failurename", ilog.getFailureFileName()); jtemp.put("log", ilog.getLog()); jtemp.put("imported", ilog.getImported()); jtemp.put("total", ilog.getTotalRecs()); jtemp.put("rejected", ilog.getRejected()); jtemp.put("type", ilog.getType()); jtemp.put("importon", df.format(ilog.getImportDate())); jtemp.put("module", ilog.getModule().getModuleName()); jtemp.put("importedby", (ilog.getUser().getFirstName() == null ? "" : ilog.getUser().getFirstName()) + " " + (ilog.getUser().getLastName() == null ? "" : ilog.getUser().getLastName())); jtemp.put("company", ilog.getCompany().getCompanyName()); jArr.put(jtemp); } jobj.put("data", jArr); jobj.put("count", result.getRecordTotalCount()); issuccess = true; } catch (Exception ex) { msg = "" + ex.getMessage(); Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, ex); } finally { try { jobj.put("success", issuccess); jobj.put("msg", msg); } catch (JSONException ex) { Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, ex); } } return new ModelAndView("jsonView", "model", jobj.toString()); }