List of usage examples for java.text SimpleDateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:com.widen.valet.Route53Driver.java
private Date parseDate(String formatDesc, String date) throws ParseException { SimpleDateFormat format = new SimpleDateFormat(formatDesc); format.setTimeZone(getTimeZone("Zulu")); return format.parse(date); }
From source file:com.achep.base.ui.fragments.dialogs.FeedbackDialog.java
private void attachLog(@NonNull Intent intent) { Context context = getActivity(); try {// ww w. ja va 2 s. co m String log = Logcat.capture(); if (log == null) throw new Exception("Failed to capture the logcat."); // Prepare cache directory. File cacheDir = context.getCacheDir(); if (cacheDir == null) throw new Exception("Cache directory is inaccessible"); File directory = new File(cacheDir, LogsProviderBase.DIRECTORY); FileUtils.deleteRecursive(directory); // Clean-up cache folder if (!directory.mkdirs()) throw new Exception("Failed to create cache directory."); // Create log file. @SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); String fileName = "AcDisplay_log_" + sdf.format(new Date()) + ".txt"; File file = new File(directory, fileName); // Write to the file. if (!FileUtils.writeToFile(file, log)) throw new Exception("Failed to write log to the file."); // Put extra stream to the intent. Uri uri = Uri.parse("content://" + LogAttachmentProvider.AUTHORITY + "/" + fileName); intent.putExtra(Intent.EXTRA_STREAM, uri); } catch (Exception e) { String message = ResUtils.getString(getResources(), R.string.feedback_error_accessing_log, e.getMessage()); ToastUtils.showLong(context, message); } }
From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java
/** * ??//from w w w. j a va2s . co m * []??? * ??????? * @param now */ private void setThisTime(Long now) { Date date = new Date(now); m_log.trace("date= " + date); SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); sdfYear.setTimeZone(HinemosTime.getTimeZone()); String strYear = sdfYear.format(date); this.year = Integer.parseInt(strYear); SimpleDateFormat sdfMonth = new SimpleDateFormat("MM"); sdfMonth.setTimeZone(HinemosTime.getTimeZone()); String strMonth = sdfMonth.format(date); this.month = Integer.parseInt(strMonth); SimpleDateFormat sdfDay = new SimpleDateFormat("dd"); sdfDay.setTimeZone(HinemosTime.getTimeZone()); String strDay = sdfDay.format(date); this.day = Integer.parseInt(strDay); SimpleDateFormat sdfHour = new SimpleDateFormat("HH"); sdfHour.setTimeZone(HinemosTime.getTimeZone()); String strHour = sdfHour.format(date); this.hour = Integer.parseInt(strHour); SimpleDateFormat sdfMinute = new SimpleDateFormat("mm"); sdfMinute.setTimeZone(HinemosTime.getTimeZone()); String strMinute = sdfMinute.format(date); this.minute = Integer.parseInt(strMinute); m_log.trace("year=" + year + ",month=" + month + ",day=" + day); }
From source file:org.jasig.schedassist.impl.caldav.CaldavEventUtilsImplTest.java
/** * Construct an appointment for an "individual" appointment (e.g. 1 visitor). * Compare with 'vevent-examples/example-individual-appointment.ics'. * //from www . ja va 2 s.c o m * @throws InputFormatException * @throws IOException * @throws ParserException * @throws ParseException */ @Test public void testConstructIndividualAppointment() throws InputFormatException, IOException, ParserException, ParseException { CaldavEventUtilsImpl eventUtils = new CaldavEventUtilsImpl(new NullAffiliationSourceImpl()); eventUtils.setExplicitSetTimeZone(false); SimpleDateFormat dateFormat = CommonDateOperations.getDateTimeFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("America/Chicago")); Date start = dateFormat.parse("20110503-0800"); Date end = dateFormat.parse("20110503-0900"); AvailableBlock block = AvailableBlockBuilder.createBlock(start, end); MockCalendarAccount ownerAccount = new MockCalendarAccount(); ownerAccount.setDisplayName("OWNER NAME"); ownerAccount.setEmailAddress("someone@wherever.org"); MockScheduleOwner owner = new MockScheduleOwner(ownerAccount, 1L); owner.setPreference(Preferences.LOCATION, "123 University Building"); MockCalendarAccount visitorAccount = new MockCalendarAccount(); visitorAccount.setDisplayName("VISITOR NAME"); visitorAccount.setEmailAddress("somevisitor@wherever.org"); MockScheduleVisitor visitor = new MockScheduleVisitor(visitorAccount); VEvent generated = eventUtils.constructAvailableAppointment(block, owner, visitor, "test reason."); Resource example = new ClassPathResource("vevent-examples/example-individual-appointment.ics"); CalendarBuilder builder = new CalendarBuilder(); Calendar expectedCalendar = builder.build(example.getInputStream()); VEvent expectedEvent = (VEvent) expectedCalendar.getComponents(VEvent.VEVENT).get(0); Assert.assertEquals(generated.getOrganizer(), expectedEvent.getOrganizer()); Assert.assertEquals(generated.getStartDate(), expectedEvent.getStartDate()); Assert.assertEquals(generated.getEndDate(), expectedEvent.getEndDate()); Assert.assertEquals(generated.getSummary(), expectedEvent.getSummary()); Assert.assertEquals(generated.getDescription(), expectedEvent.getDescription()); Assert.assertEquals(generated.getProperty(VisitorLimit.VISITOR_LIMIT), expectedEvent.getProperty(VisitorLimit.VISITOR_LIMIT)); // verify owner and visitor have correct roles in the example Assert.assertTrue(eventUtils.isAttendingAsOwner(expectedEvent, ownerAccount)); Assert.assertTrue(eventUtils.isAttendingAsVisitor(expectedEvent, visitorAccount)); // verify owner and visitor have same roles in the generated event Assert.assertTrue(eventUtils.isAttendingAsOwner(generated, ownerAccount)); Assert.assertTrue(eventUtils.isAttendingAsVisitor(generated, visitorAccount)); }
From source file:org.jasig.schedassist.impl.caldav.CaldavEventUtilsImplTest.java
@Test public void testConstructIndividualAppointmentSetTimeZone() throws Exception { CaldavEventUtilsImpl eventUtils = new CaldavEventUtilsImpl(new NullAffiliationSourceImpl()); eventUtils.setExplicitSetTimeZone(true); eventUtils.setTimeZone("America/Chicago"); eventUtils.afterPropertiesSet();//from w w w.java 2 s . co m SimpleDateFormat dateFormat = CommonDateOperations.getDateTimeFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("America/Chicago")); Date start = dateFormat.parse("20110503-0800"); Date end = dateFormat.parse("20110503-0900"); AvailableBlock block = AvailableBlockBuilder.createBlock(start, end); MockCalendarAccount ownerAccount = new MockCalendarAccount(); ownerAccount.setDisplayName("OWNER NAME"); ownerAccount.setEmailAddress("someone@wherever.org"); MockScheduleOwner owner = new MockScheduleOwner(ownerAccount, 1L); owner.setPreference(Preferences.LOCATION, "123 University Building"); MockCalendarAccount visitorAccount = new MockCalendarAccount(); visitorAccount.setDisplayName("VISITOR NAME"); visitorAccount.setEmailAddress("somevisitor@wherever.org"); MockScheduleVisitor visitor = new MockScheduleVisitor(visitorAccount); VEvent generated = eventUtils.constructAvailableAppointment(block, owner, visitor, "test reason."); Resource example = new ClassPathResource( "vevent-examples/example-individual-appointment-with-explicit-timezone.ics"); CalendarBuilder builder = new CalendarBuilder(); Calendar expectedCalendar = builder.build(example.getInputStream()); VEvent expectedEvent = (VEvent) expectedCalendar.getComponents(VEvent.VEVENT).get(0); Assert.assertEquals(generated.getOrganizer(), expectedEvent.getOrganizer()); Assert.assertEquals(generated.getStartDate(), expectedEvent.getStartDate()); Assert.assertEquals(generated.getEndDate(), expectedEvent.getEndDate()); Assert.assertEquals(generated.getSummary(), expectedEvent.getSummary()); Assert.assertEquals(generated.getDescription(), expectedEvent.getDescription()); Assert.assertEquals(generated.getProperty(VisitorLimit.VISITOR_LIMIT), expectedEvent.getProperty(VisitorLimit.VISITOR_LIMIT)); // verify owner and visitor have correct roles in the example Assert.assertTrue(eventUtils.isAttendingAsOwner(expectedEvent, ownerAccount)); Assert.assertTrue(eventUtils.isAttendingAsVisitor(expectedEvent, visitorAccount)); // verify owner and visitor have same roles in the generated event Assert.assertTrue(eventUtils.isAttendingAsOwner(generated, ownerAccount)); Assert.assertTrue(eventUtils.isAttendingAsVisitor(generated, visitorAccount)); }
From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java
private void updateDownlodCounter(String pluginId) { if (!registry.contains("registry.cordova.io"))//ping only cordova registry return;/*from w w w .j a v a 2s . co m*/ HttpClient client = new DefaultHttpClient(); String url = registry.endsWith("/") ? registry + "downloads" : registry + "/downloads"; HttpPost post = new HttpPost(url); Date now = new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM.dd"); df.setTimeZone(TimeZone.getTimeZone("UTC")); JsonObject obj = new JsonObject(); obj.addProperty("day", df.format(now)); obj.addProperty("pkg", pluginId); obj.addProperty("client", REGISTRY_CLIENT_ID); Gson gson = new Gson(); String json = gson.toJson(obj); StringEntity entity; try { entity = new StringEntity(json); entity.setContentType("application/json"); post.setEntity(entity); HttpResponse response = client.execute(post); if (response.getStatusLine().getStatusCode() != 201) { HybridCore.log(IStatus.INFO, "Unable to ping Cordova registry download counter", null); } } catch (UnsupportedEncodingException e) { HybridCore.log(IStatus.INFO, "Unable to ping Cordova registry download counter", e); } catch (IOException e) { HybridCore.log(IStatus.INFO, "Unable to ping Cordova registry download counter", e); } }
From source file:com.clustercontrol.custom.factory.RunCustomString.java
/** * ????<br/>// w w w.j a v a 2 s .co 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 msg = ""; String msgOrig = ""; boolean isMonitorJob = result.getRunInstructionInfo() != null; // MAIN try { monitor = new MonitorSettingControllerBean().getMonitor(result.getMonitorId()); String executeDate = dateFormat.format(result.getExecuteDate()); String exitDate = dateFormat.format(result.getExitDate()); String collectDate = dateFormat.format(result.getCollectDate()); facilityPath = new RepositoryControllerBean().getFacilityPath(result.getFacilityId(), null); if (result.getTimeout() || result.getStdout() == null || result.getStdout().isEmpty() || 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_S); } else { // this.monitorJobEndNodeList.add(new MonitorJobEndNode(result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_S, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue( result.getRunInstructionInfo(), PriorityConstant.TYPE_UNKNOWN))); } } } else { // if command stdout was returned Monitor msg = result.getStdout(); // Stdout??? Pattern patternMsg = Pattern.compile("\r\n$|\n$"); Matcher matcherMsg = patternMsg.matcher(msg); msg = matcherMsg.replaceAll(""); if (m_log.isDebugEnabled()) { m_log.debug("command monitoring : values [" + msg + "]"); } // ? if (monitor.getCollectorFlg()) { // collector each value List<StringSample> sampleList = new ArrayList<StringSample>(); StringSample sample = new StringSample(new Date(HinemosTime.currentTimeMillis()), monitor.getMonitorId()); // sample.set(result.getFacilityId(), "custom", msg); sampleList.add(sample); if (!sampleList.isEmpty()) { CollectStringDataUtil.store(sampleList); } } // int orderNo = 0; if (isMonitorJob || monitor.getMonitorFlg()) { // monitor each value for (MonitorStringValueInfo stringValueInfo : monitor.getStringValueInfo()) { ++orderNo; if (m_log.isDebugEnabled()) { m_log.info(String.format( "monitoring (monitorId = %s, orderNo = %d, patten = %s, enabled = %s, casesensitive = %s)", monitor.getMonitorId(), orderNo, stringValueInfo.getPattern(), stringValueInfo.getValidFlg(), stringValueInfo.getCaseSensitivityFlg())); } if (!stringValueInfo.getValidFlg()) { // ????? continue; } // ? if (m_log.isDebugEnabled()) { m_log.debug(String.format("filtering customtrap (regex = %s, Msg = %s", stringValueInfo.getPattern(), msg)); } try { Pattern pattern = null; if (stringValueInfo.getCaseSensitivityFlg()) { // ????? pattern = Pattern.compile(stringValueInfo.getPattern(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE); } else { // ??? pattern = Pattern.compile(stringValueInfo.getPattern(), Pattern.DOTALL); } Matcher matcher = pattern.matcher(msg); if (matcher.matches()) { if (stringValueInfo.getProcessType()) { msgOrig = MessageConstant.LOGFILE_PATTERN.getMessage() + "=" + stringValueInfo.getPattern() + "\n" + MessageConstant.LOGFILE_LINE.getMessage() + "=" + msg + "\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"; msg = makeMsg(stringValueInfo, msg); priority = stringValueInfo.getPriority(); if (!isMonitorJob) { // notify(priority, monitor, result.getFacilityId(), facilityPath, stringValueInfo.getPattern(), msg, msgOrig, HinemosModuleConstant.MONITOR_CUSTOM_S); } else { // this.monitorJobEndNodeList .add(new MonitorJobEndNode(result.getRunInstructionInfo(), HinemosModuleConstant.MONITOR_CUSTOM_S, makeJobOrgMessage(monitor, msgOrig), "", RunStatusConstant.END, MonitorJobWorker.getReturnValue( result.getRunInstructionInfo(), priority))); } } else { m_log.debug(String.format("not ProcessType (regex = %s, Msg = %s", stringValueInfo.getPattern(), result.getStdout())); } break;// Syslog?????? } } catch (RuntimeException e) { m_log.warn("filtering failure. (regex = " + stringValueInfo.getPattern() + ") . " + e.getMessage(), e); } } } } } catch (MonitorNotFound | CustomInvalid | 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:co.uk.randompanda30.sao.modules.util.BackupUtil.java
public void backup() { TEMP.isBackingup = true;/*from w w w. j av a 2s . c o m*/ SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy-HH:mm:ss-z"); f.setTimeZone(TimeZone.getTimeZone("Europe/London")); ArrayList<File> fq = new ArrayList<>(); File ff = new File(toStore); FileUtils.listFiles(ff, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).stream() .filter(fff -> fff.getName().endsWith(".zip")).forEach(fq::add); if (!fq.isEmpty() && fq.size() >= 5) { File[] fil = fq.toArray(new File[fq.size()]); Arrays.sort(fil, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); fil[0].delete(); } size = 0; files = 0; p = 0; lp = -1; time = f.format(GregorianCalendar.getInstance().getTime()); logFile = new File(toStoreLogs + time + ".log"); if (!new File(toStore).exists()) { new File(toStore).mkdir(); } if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } Dispatch.sendMessage((String) Messages.MessagesValues.MODULES_BACKUP_STARTED.value, null); Bukkit.getOnlinePlayers().stream().filter(player -> player.hasPermission("backup.notification")) .forEach(player -> Dispatch .sendMessage((String) Messages.MessagesValues.MODULES_BACKUP_STARTED.value, player)); Thread t = new Thread(new Runnable() { boolean nc = false; @Override public void run() { String s = "zip -r " + toStore + time + ".zip " + toBackup; for (String exclusion : (List<String>) Config.ConfigValues.BACKUP_EXCLUSIONPATHS.value) { String nex = exclusion.endsWith("/") ? exclusion : exclusion + "/"; s += " -x " + toBackup + nex + "\\" + "*"; } startBackupTimer(); File file = new File(toBackup); // FileUtils.listFiles(file, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE) listFDIR(file.getAbsolutePath()); try { Process process = Runtime.getRuntime().exec(s); InputStreamReader is = new InputStreamReader(process.getInputStream()); BufferedReader buff = new BufferedReader(is); FileOutputStream fos = new FileOutputStream(logFile); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); String line; while ((line = buff.readLine()) != null) { files++; bw.write(line); bw.newLine(); updatePercentage(); } bw.close(); } catch (IOException e) { e.printStackTrace(); } nc = true; Dispatch.sendMessage((String) Messages.MessagesValues.MODULES_BACKUP_STOPPED.value, null); Bukkit.getOnlinePlayers().stream().filter(player -> player.hasPermission("backup.notification")) .forEach(player -> Dispatch.sendMessage( (String) Messages.MessagesValues.MODULES_BACKUP_STOPPED.value, player)); if (TEMP.pendingRestart) { // Message new ShutdownTask().runTaskTimer(SAO.getPlugin(), 0L, 20L); } } private void updatePercentage() { double d = (files / size) * 100; p = (int) d; } private void startBackupTimer() { new BukkitRunnable() { @Override public void run() { if (!nc) { String m = (String) Messages.MessagesValues.MODULES_BACKUP_PERCENTAGE.value; m = m.replace("%perc", Integer.toString(p)); m = m.replace("%done", Integer.toString((int) files)); m = m.replace("%files", Integer.toString((int) size)); if (p != lp) { lp = p; Dispatch.sendMessage(m, null); for (Player player : Bukkit.getOnlinePlayers()) { if (player.hasPermission("backup.notification")) { Dispatch.sendMessage(m, player); } } } } else { TEMP.isBackingup = false; startTimer(); this.cancel(); } } }.runTaskTimer(SAO.getPlugin(), 0L, 100L); } }); t.start(); }
From source file:calendarexportplugin.exporter.GoogleExporter.java
public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) { try {//w w w .j a v a2 s .com boolean uploadedItems = false; mPassword = IOUtilities.xorDecode(settings.getExporterProperty(PASSWORD), 345903).trim(); if (!settings.getExporterProperty(STORE_PASSWORD, false)) { if (!showLoginDialog(settings)) { return false; } } if (!settings.getExporterProperty(STORE_SETTINGS, false)) { if (!showCalendarSettings(settings)) { return false; } } GoogleService myService = new GoogleService("cl", "tvbrowser-tvbrowsercalenderplugin-" + CalendarExportPlugin.getInstance().getInfo().getVersion().toString()); myService.setUserCredentials(settings.getExporterProperty(USERNAME).trim(), mPassword); URL postUrl = new URL("http://www.google.com/calendar/feeds/" + settings.getExporterProperty(SELECTED_CALENDAR) + "/private/full"); SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd"); formatDay.setTimeZone(TimeZone.getTimeZone("GMT")); SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss"); formatTime.setTimeZone(TimeZone.getTimeZone("GMT")); ParamParser parser = new ParamParser(); for (Program program : programs) { final String title = parser.analyse(formatting.getTitleValue(), program); // First step: search for event in calendar boolean createEvent = true; CalendarEventEntry entry = findEntryForProgram(myService, postUrl, title, program); if (entry != null) { int ret = JOptionPane.showConfirmDialog(null, mLocalizer.msg("alreadyAvailable", "already available", program.getTitle()), mLocalizer.msg("title", "Add event?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret != JOptionPane.YES_OPTION) { createEvent = false; } } // add event to calendar if (createEvent) { EventEntry myEntry = new EventEntry(); myEntry.setTitle(new PlainTextConstruct(title)); String desc = parser.analyse(formatting.getContentValue(), program); myEntry.setContent(new PlainTextConstruct(desc)); Calendar c = CalendarToolbox.getStartAsCalendar(program); DateTime startTime = new DateTime(c.getTime(), c.getTimeZone()); c = CalendarToolbox.getEndAsCalendar(program); DateTime endTime = new DateTime(c.getTime(), c.getTimeZone()); When eventTimes = new When(); eventTimes.setStartTime(startTime); eventTimes.setEndTime(endTime); myEntry.addTime(eventTimes); if (settings.getExporterProperty(REMINDER, false)) { int reminderMinutes = 0; try { reminderMinutes = settings.getExporterProperty(REMINDER_MINUTES, 0); } catch (NumberFormatException e) { e.printStackTrace(); } if (settings.getExporterProperty(REMINDER_ALERT, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.ALERT); } if (settings.getExporterProperty(REMINDER_EMAIL, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.EMAIL); } if (settings.getExporterProperty(REMINDER_SMS, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.SMS); } } if (settings.isShowBusy()) { myEntry.setTransparency(BaseEventEntry.Transparency.OPAQUE); } else { myEntry.setTransparency(BaseEventEntry.Transparency.TRANSPARENT); } // Send the request and receive the response: myService.insert(postUrl, myEntry); uploadedItems = true; } } if (uploadedItems) { JOptionPane.showMessageDialog(CalendarExportPlugin.getInstance().getBestParentFrame(), mLocalizer.msg("exportDone", "Google Export done."), mLocalizer.msg("export", "Export"), JOptionPane.INFORMATION_MESSAGE); } return true; } catch (AuthenticationException e) { ErrorHandler.handle(mLocalizer.msg("loginFailure", "Problems during login to Service.\nMaybe bad username or password?"), e); settings.setExporterProperty(STORE_PASSWORD, false); } catch (Exception e) { ErrorHandler.handle(mLocalizer.msg("commError", "Error while communicating with Google!"), e); } return false; }
From source file:com.persistent.cloudninja.controller.CloudNinjaAuthFilter.java
private void forwardToLandingPage(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain chain, CloudNinjaUser cloudNinjaUser) { UserActivityQueue userActivityQueue = UserActivityQueue.getUserActivityQueue(); String tenantId = null;/*from ww w.j a v a 2 s . c om*/ synchronized (userActivityQueue) { try { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String date = dateFormat.format(calendar.getTime()); UserActivityQueueMessage message; String cookie = httpServletRequest.getAttribute("cookieNameAttr").toString(); tenantId = AuthFilterUtils.getFieldValueFromCookieString(CloudNinjaConstants.COOKIE_TENANTID_PREFIX, cookie); message = new UserActivityQueueMessage(tenantId, cloudNinjaUser.getMemberId(), dateFormat.parse(date)); userActivityQueue.add(message); } catch (ParseException e) { e.printStackTrace(); } } try { rsBundle = ResourceBundle.getBundle("acs"); String landingPageURL = "/" + tenantId; landingPageURL = landingPageURL + rsBundle.getString("tenant.dashboard.landing.page.url").trim(); httpServletRequest.getRequestDispatcher(landingPageURL).forward(httpServletRequest, httpServletResponse); } catch (ServletException exception) { logger.error(exception.getMessage()); exception.printStackTrace(); } catch (IOException exception) { logger.error(exception.getMessage()); exception.printStackTrace(); } }