List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:jef.tools.DateUtils.java
/** * ????? ??/*from www . j a va 2 s. c o m*/ * * @param d * @param unit * @return */ public static boolean isOnTime(Date d, TimeUnit unit) { return isOnTime(d, unit, TimeZone.getDefault()); }
From source file:com.krawler.spring.calendar.calendarmodule.crmCalendarController.java
public ModelAndView getAllEvents(HttpServletRequest request, HttpServletResponse response) throws ServletException { List<CalendarEvent> result = null; List<CalendarEvent> modEvents = null; TimeZone tz;/*from w w w . ja va2 s . c o m*/ try { tz = TimeZone.getTimeZone("GMT" + sessionHandlerImpl.getTimeZoneDifference(request)); } catch (SessionExpiredException e1) { tz = TimeZone.getDefault(); } try { List<CalendarEvent> temp; if (request.getParameter("calView").equals("1")) { String[] cidList = request.getParameterValues("cidList"); Long viewdt1 = Long.parseLong(request.getParameter("viewdt1")); Long viewdt2 = Long.parseLong(request.getParameter("viewdt2")); int limit = Integer.parseInt(request.getParameter("limit")); int offset = Integer.parseInt(request.getParameter("start")); temp = calendarEventService.getEvents(cidList, new Date(viewdt1), new Date(viewdt2), offset, limit); } else { String[] cid = request.getParameterValues("cid"); temp = calendarEventService.getEvents(cid); } if (temp != null) { result = new ArrayList<CalendarEvent>(); for (CalendarEvent e : temp) { if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) { List durations = calendarEventService.breakDuration(e.getDuration(), tz); if (durations.size() > 1) result.addAll(calendarEventService.breakEvent(e, durations)); else result.add(e); } else { result.add(e); } } } StringBuffer usersList = sessionHandlerImpl.getRecursiveUsersList(request); if (moduleEventServices != null) { HashMap<String, Object> params = null; if (request.getParameter("calView").equals("1")) { params = new HashMap<String, Object>(); Long stDate = Long.parseLong(request.getParameter("viewdt1")); Long edDate = Long.parseLong(request.getParameter("viewdt2")); params.put("from", stDate); params.put("to", edDate); } for (ModuleEventService mes : moduleEventServices) { modEvents = mes.getEvents(usersList, params); if (modEvents != null) { for (CalendarEvent e : modEvents) { try { if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) { List durations = calendarEventService.breakDuration(e.getDuration(), tz); if (durations.size() > 1) result.addAll(calendarEventService.breakEvent(e, durations)); else result.add(e); } else { result.add(e); } } catch (Exception ev) { logger.warn(ev.getMessage()); } } } } } } catch (Exception e) { logger.warn(e.getMessage()); } SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); fmt.setTimeZone(tz); EventJSONMapper mapper = new EventJSONMapper(); mapper.setDateFormat(fmt); return new ModelAndView(new CalendarView(mapper, "data"), "data", result); }
From source file:hydrograph.ui.dataviewer.adapters.DataViewerAdapter.java
/** * Initialize table data.//from www . j av a 2 s.co m * * @throws SQLException * the SQL exception * @throws IOException * Signals that an I/O exception has occurred. */ public void initializeTableData() throws SQLException, IOException { List<Integer> timeStampColumnIndexList = getTimeStampColumnIndexList(); viewerData.clear(); String sql; if (filterCondition != null && !filterCondition.isEmpty()) { sql = new ViewDataQueryBuilder(tableName).limit(pageSize).offset(offset).getQuery(filterCondition); } else { sql = new ViewDataQueryBuilder(tableName).limit(pageSize).offset(offset).getQuery(""); } ResultSet results = statement.executeQuery(sql); int rowIndex = 1; while (results.next()) { List<RowField> row = new LinkedList<>(); int timeStampIndex = 1; for (int index = 1; index <= columnCount; index++) { boolean timeStampColumn = false; for (int i = timeStampIndex; i <= timeStampColumnIndexList.size(); i++) { if (index == timeStampColumnIndexList.get(i - 1)) { try { int zoneOffset = TimeZone.getDefault().getRawOffset(); SimpleDateFormat formatter = new SimpleDateFormat(AdapterConstants.DATE_FORMAT); Date parsedDate = formatter.parse(results.getString(index)); Long time = parsedDate.getTime(); long zoneLessTime = time - zoneOffset; Date zoneLessDate = new Date(zoneLessTime); String debugFileName = debugDataViewer.getDebugFileName(); String debugFileLocation = debugDataViewer.getDebugFileLocation(); Fields dataViewerFileSchema = ViewDataSchemaHelper.INSTANCE.getFieldsFromSchema( debugFileLocation + debugFileName + AdapterConstants.SCHEMA_FILE_EXTENTION); int counter = 1; String format = ""; for (Field field : dataViewerFileSchema.getField()) { if (index == counter) { format = field.getFormat(); break; } counter++; } SimpleDateFormat desiredDateFormat = new SimpleDateFormat(format); String timestampDate = desiredDateFormat.format(zoneLessDate); row.add(new RowField(timestampDate)); timeStampIndex++; timeStampColumn = true; break; } catch (ParseException pe) { logger.error("Error while parsing date value", pe); } } } if (!timeStampColumn) row.add(new RowField(results.getString(index))); } viewerData.add(new RowData(row, rowIndex)); rowIndex++; } results.close(); }
From source file:cn.com.incito.driver.fragments.infocenter.MyInfoFragment.java
private void initData() { locationCity = mShare.getString(Constants.LOCATION_CITY, "").split("")[0]; // /* w w w . j a v a 2 s . com*/ // initWeather();//???? // Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); cal.setTimeZone(TimeZone.getDefault()); // System.out.println(":"+sdf.format(cal.getTime())); mTime.setText(sdf.format(cal.getTime())); LunarUtil lunar = new LunarUtil(cal); mDate.setText(lunar.toString()); if (NetworkUtils.isNetworkAvaliable(getActivity())) { MyInfoCenterAPI myInfoCenterAPI = new MyInfoCenterAPI(GlobalModel.getInst().mLoginModel.getCarId(), locationCity); new WisdomCityHttpResponseHandler(myInfoCenterAPI, new APIFinishCallback() { @Override public void OnRemoteApiFinish(BasicResponse response) { if (response.status == BasicResponse.SUCCESS) { MyInfoCenterAPIResponse myInfoCenterAPIResponse = (MyInfoCenterAPIResponse) response; // initNotices(myInfoCenterAPIResponse.mNoticesList); // ? initTransport(myInfoCenterAPIResponse.mModelTransport); // ? initModelCar(myInfoCenterAPIResponse.mCar); // ? initGoods(myInfoCenterAPIResponse.mGoodsTotal); // ? initOrder(myInfoCenterAPIResponse.mMyOrdersTotal); // initAgentInfo(myInfoCenterAPIResponse.mAgentList); } else { } } }); WisdomCityRestClient.execute(myInfoCenterAPI); } else { Toast.makeText(getActivity(), R.string.errcode_network_unavailable, Toast.LENGTH_SHORT).show(); } }
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Some checks for the getEnd() method.//ww w . jav a2s .co m */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 59); cal.set(Calendar.MILLISECOND, 999); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:ch.algotrader.service.CalendarServiceImpl.java
private boolean isTradingDay(final Exchange exchange, final Date date) { Validate.notNull(exchange, "exchange not found"); Validate.notNull(date, "date is null"); // is this date a holiday? Holiday holiday = getHoliday(exchange, date); if (holiday != null && !holiday.isPartialOpen()) { return false; }/*from ww w . jav a 2 s . c o m*/ Validate.isTrue(exchange.getTradingHours().size() > 0, "no trading hours defined for exchange " + exchange); // check if any of the tradingHours is enabled for this date WeekDay weekDay = getWeekDay(date, TimeZone.getDefault()); for (TradingHours tradingHours : exchange.getTradingHours()) { if (tradingHours.isEnabled(weekDay)) { return true; } } return false; }
From source file:com.whizzosoftware.hobson.scheduler.ical.ICalTaskProviderTest.java
@Test public void testDelayedDayReset() throws Exception { TimeZone tz = TimeZone.getDefault(); // an event that runs every day at midnight String ical = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "BEGIN:VEVENT\n" + "UID:15dee4fe-a841-4cf6-8d7f-76c3ad5492b1\n" + "DTSTART:20140701T000000\n" + "RRULE:FREQ=DAILY\n" + "SUMMARY:My Task\n" + "COMMENT:[{'pluginId':'com.whizzosoftware.hobson.server-api','actionId':'log','name':'My Action','properties':{'message':'Test'}}]\n" + "END:VEVENT\n" + "END:VCALENDAR"; // start the scheduler after the task should have run MockScheduledTaskExecutor executor = new MockScheduledTaskExecutor(); MockActionManager actionManager = new MockActionManager(); ICalTaskProvider s = new ICalTaskProvider("pluginId", null, null, tz); s.setScheduleExecutor(executor);/* ww w . j a v a2s .c o m*/ s.setActionManager(actionManager); s.loadICSStream(new ByteArrayInputStream(ical.getBytes()), DateHelper.getTime(tz, 2014, 7, 1, 17, 0, 0)); // verify task was not scheduled assertEquals(1, s.getTasks().size()); assertFalse(executor.isTaskScheduled((ICalTask) s.getTasks().iterator().next())); assertEquals(0, actionManager.getLogCalls()); // start a new day 30 seconds after midnight -- this covers the corner case where a delay causes the // resetForNewDay() method to get fired slightly after midnight and there are tasks that should have // already executed by then s.resetForNewDay(DateHelper.getTime(tz, 2014, 7, 2, 0, 0, 30)); // verify task was not scheduled but task executed assertEquals(1, s.getTasks().size()); ICalTask task = (ICalTask) s.getTasks().iterator().next(); assertFalse(executor.isTaskScheduled(task)); assertEquals(1404367200000l, task.getProperties().get(ICalTask.PROP_NEXT_RUN_TIME)); assertFalse((boolean) task.getProperties().get(ICalTask.PROP_SCHEDULED)); assertEquals(1, actionManager.getLogCalls()); }
From source file:ching.icecreaming.action.ViewAction.java
@Action(value = "view", results = { @Result(name = "login", location = "edit.jsp"), @Result(name = "input", location = "view.jsp"), @Result(name = "success", location = "view.jsp"), @Result(name = "error", location = "error.jsp") }) public String execute() throws Exception { Enumeration enumerator = null; String[] array1 = null, array2 = null; int int1 = -1, int2 = -1, int3 = -1; InputStream inputStream1 = null; OutputStream outputStream1 = null; java.io.File file1 = null, file2 = null, dir1 = null; List<File> files = null; HttpHost httpHost1 = null;//ww w . ja v a2 s. c om HttpGet httpGet1 = null, httpGet2 = null; HttpPut httpPut1 = null; URI uri1 = null; URL url1 = null; DefaultHttpClient httpClient1 = null; URIBuilder uriBuilder1 = null, uriBuilder2 = null; HttpResponse httpResponse1 = null, httpResponse2 = null; HttpEntity httpEntity1 = null, httpEntity2 = null; List<NameValuePair> nameValuePair1 = null; String string1 = null, string2 = null, string3 = null, string4 = null, return1 = LOGIN; XMLConfiguration xmlConfiguration = null; List<HierarchicalConfiguration> list1 = null, list2 = null; HierarchicalConfiguration hierarchicalConfiguration2 = null; DataModel1 dataModel1 = null; DataModel2 dataModel2 = null; List<DataModel1> listObject1 = null, listObject3 = null; org.joda.time.DateTime dateTime1 = null, dateTime2 = null; org.joda.time.Period period1 = null; PeriodFormatter periodFormatter1 = new PeriodFormatterBuilder().appendYears() .appendSuffix(String.format(" %s", getText("year")), String.format(" %s", getText("years"))) .appendSeparator(" ").appendMonths() .appendSuffix(String.format(" %s", getText("month")), String.format(" %s", getText("months"))) .appendSeparator(" ").appendWeeks() .appendSuffix(String.format(" %s", getText("week")), String.format(" %s", getText("weeks"))) .appendSeparator(" ").appendDays() .appendSuffix(String.format(" %s", getText("day")), String.format(" %s", getText("days"))) .appendSeparator(" ").appendHours() .appendSuffix(String.format(" %s", getText("hour")), String.format(" %s", getText("hours"))) .appendSeparator(" ").appendMinutes() .appendSuffix(String.format(" %s", getText("minute")), String.format(" %s", getText("minutes"))) .appendSeparator(" ").appendSeconds().minimumPrintedDigits(2) .appendSuffix(String.format(" %s", getText("second")), String.format(" %s", getText("seconds"))) .printZeroNever().toFormatter(); if (StringUtils.isBlank(urlString) || StringUtils.isBlank(wsType)) { urlString = portletPreferences.getValue("urlString", "/"); wsType = portletPreferences.getValue("wsType", "folder"); } Configuration propertiesConfiguration1 = new PropertiesConfiguration("system.properties"); timeZone1 = portletPreferences.getValue("timeZone", TimeZone.getDefault().getID()); enumerator = portletPreferences.getNames(); if (enumerator.hasMoreElements()) { array1 = portletPreferences.getValues("server", null); if (array1 != null) { if (ArrayUtils.isNotEmpty(array1)) { for (int1 = 0; int1 < array1.length; int1++) { switch (int1) { case 0: sid = array1[int1]; break; case 1: uid = array1[int1]; break; case 2: pid = array1[int1]; break; case 3: alias1 = array1[int1]; break; default: break; } } sid = new String(Base64.decodeBase64(sid.getBytes())); uid = new String(Base64.decodeBase64(uid.getBytes())); pid = new String(Base64.decodeBase64(pid.getBytes())); } return1 = INPUT; } else { return1 = LOGIN; } } else { return1 = LOGIN; } if (StringUtils.equals(urlString, "/")) { if (listObject1 != null) { listObject1.clear(); } if (session.containsKey("breadcrumbs")) { session.remove("breadcrumbs"); } } else { array2 = StringUtils.split(urlString, "/"); listObject1 = (session.containsKey("breadcrumbs")) ? (List<DataModel1>) session.get("breadcrumbs") : new ArrayList<DataModel1>(); int2 = array2.length - listObject1.size(); if (int2 > 0) { listObject1.add(new DataModel1(urlString, label1)); } else { int2 += listObject1.size(); for (int1 = listObject1.size() - 1; int1 >= int2; int1--) { listObject1.remove(int1); } } session.put("breadcrumbs", listObject1); } switch (wsType) { case "folder": break; case "reportUnit": try { dateTime1 = new org.joda.time.DateTime(); return1 = INPUT; httpClient1 = new DefaultHttpClient(); if (StringUtils.equals(button1, getText("Print"))) { nameValuePair1 = new ArrayList<NameValuePair>(); if (listObject2 != null) { if (listObject2.size() > 0) { for (DataModel2 dataObject2 : listObject2) { listObject3 = dataObject2.getOptions(); if (listObject3 == null) { string2 = dataObject2.getValue1(); if (StringUtils.isNotBlank(string2)) nameValuePair1.add(new BasicNameValuePair(dataObject2.getId(), string2)); } else { for (int1 = listObject3.size() - 1; int1 >= 0; int1--) { dataModel1 = (DataModel1) listObject3.get(int1); string2 = dataModel1.getString2(); if (StringUtils.isNotBlank(string2)) nameValuePair1 .add(new BasicNameValuePair(dataObject2.getId(), string2)); } } } } } url1 = new URL(sid); uriBuilder1 = new URIBuilder(sid); uriBuilder1.setUserInfo(uid, pid); if (StringUtils.isBlank(format1)) format1 = "pdf"; uriBuilder1.setPath(url1.getPath() + "/rest_v2/reports" + urlString + "." + format1); if (StringUtils.isNotBlank(locale2)) { nameValuePair1.add(new BasicNameValuePair("userLocale", locale2)); } if (StringUtils.isNotBlank(page1)) { if (NumberUtils.isNumber(page1)) { nameValuePair1.add(new BasicNameValuePair("page", page1)); } } if (nameValuePair1.size() > 0) { uriBuilder1.setQuery(URLEncodedUtils.format(nameValuePair1, "UTF-8")); } uri1 = uriBuilder1.build(); httpGet1 = new HttpGet(uri1); httpResponse1 = httpClient1.execute(httpGet1); int1 = httpResponse1.getStatusLine().getStatusCode(); if (int1 == HttpStatus.SC_OK) { string3 = System.getProperty("java.io.tmpdir") + File.separator + httpServletRequest.getSession().getId(); dir1 = new File(string3); if (!dir1.exists()) { dir1.mkdir(); } httpEntity1 = httpResponse1.getEntity(); file1 = new File(string3, StringUtils.substringAfterLast(urlString, "/") + "." + format1); if (StringUtils.equalsIgnoreCase(format1, "html")) { result1 = EntityUtils.toString(httpEntity1); FileUtils.writeStringToFile(file1, result1); array1 = StringUtils.substringsBetween(result1, "<img src=\"", "\""); if (ArrayUtils.isNotEmpty(array1)) { dir1 = new File( string3 + File.separator + FilenameUtils.getBaseName(file1.getName())); if (dir1.exists()) { FileUtils.deleteDirectory(dir1); } file2 = new File(FilenameUtils.getFullPath(file1.getAbsolutePath()) + FilenameUtils.getBaseName(file1.getName()) + ".zip"); if (file2.exists()) { if (FileUtils.deleteQuietly(file2)) { } } for (int2 = 0; int2 < array1.length; int2++) { try { string2 = url1.getPath() + "/rest_v2/reports" + urlString + "/" + StringUtils.substringAfter(array1[int2], "/"); uriBuilder1.setPath(string2); uri1 = uriBuilder1.build(); httpGet1 = new HttpGet(uri1); httpResponse1 = httpClient1.execute(httpGet1); int1 = httpResponse1.getStatusLine().getStatusCode(); } finally { if (int1 == HttpStatus.SC_OK) { try { string2 = StringUtils.substringBeforeLast(array1[int2], "/"); dir1 = new File(string3 + File.separator + string2); if (!dir1.exists()) { dir1.mkdirs(); } httpEntity1 = httpResponse1.getEntity(); inputStream1 = httpEntity1.getContent(); } finally { string1 = StringUtils.substringAfterLast(array1[int2], "/"); file2 = new File(string3 + File.separator + string2, string1); outputStream1 = new FileOutputStream(file2); IOUtils.copy(inputStream1, outputStream1); } } } } outputStream1 = new FileOutputStream( FilenameUtils.getFullPath(file1.getAbsolutePath()) + FilenameUtils.getBaseName(file1.getName()) + ".zip"); ArchiveOutputStream archiveOutputStream1 = new ArchiveStreamFactory() .createArchiveOutputStream(ArchiveStreamFactory.ZIP, outputStream1); archiveOutputStream1.putArchiveEntry(new ZipArchiveEntry(file1, file1.getName())); IOUtils.copy(new FileInputStream(file1), archiveOutputStream1); archiveOutputStream1.closeArchiveEntry(); dir1 = new File(FilenameUtils.getFullPath(file1.getAbsolutePath()) + FilenameUtils.getBaseName(file1.getName())); files = (List<File>) FileUtils.listFiles(dir1, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); for (File file3 : files) { archiveOutputStream1.putArchiveEntry(new ZipArchiveEntry(file3, StringUtils .substringAfter(file3.getCanonicalPath(), string3 + File.separator))); IOUtils.copy(new FileInputStream(file3), archiveOutputStream1); archiveOutputStream1.closeArchiveEntry(); } archiveOutputStream1.close(); } bugfixGateIn = propertiesConfiguration1.getBoolean("bugfixGateIn", false); string4 = bugfixGateIn ? String.format("<img src=\"%s/namespace1/file-link?sessionId=%s&fileName=", portletRequest.getContextPath(), httpServletRequest.getSession().getId()) : String.format("<img src=\"%s/namespace1/file-link?fileName=", portletRequest.getContextPath()); result1 = StringUtils.replace(result1, "<img src=\"", string4); } else { inputStream1 = httpEntity1.getContent(); outputStream1 = new FileOutputStream(file1); IOUtils.copy(inputStream1, outputStream1); result1 = file1.getAbsolutePath(); } return1 = SUCCESS; } else { addActionError(String.format("%s %d: %s", getText("Error"), int1, getText(Integer.toString(int1)))); } dateTime2 = new org.joda.time.DateTime(); period1 = new Period(dateTime1, dateTime2.plusSeconds(1)); message1 = getText("Execution.time") + ": " + periodFormatter1.print(period1); } else { url1 = new URL(sid); uriBuilder1 = new URIBuilder(sid); uriBuilder1.setUserInfo(uid, pid); uriBuilder1.setPath(url1.getPath() + "/rest_v2/reports" + urlString + "/inputControls"); uri1 = uriBuilder1.build(); httpGet1 = new HttpGet(uri1); httpResponse1 = httpClient1.execute(httpGet1); int1 = httpResponse1.getStatusLine().getStatusCode(); switch (int1) { case HttpStatus.SC_NO_CONTENT: break; case HttpStatus.SC_OK: httpEntity1 = httpResponse1.getEntity(); if (httpEntity1 != null) { inputStream1 = httpEntity1.getContent(); if (inputStream1 != null) { xmlConfiguration = new XMLConfiguration(); xmlConfiguration.load(inputStream1); list1 = xmlConfiguration.configurationsAt("inputControl"); if (list1.size() > 0) { listObject2 = new ArrayList<DataModel2>(); for (HierarchicalConfiguration hierarchicalConfiguration1 : list1) { string2 = hierarchicalConfiguration1.getString("type"); dataModel2 = new DataModel2(); dataModel2.setId(hierarchicalConfiguration1.getString("id")); dataModel2.setLabel1(hierarchicalConfiguration1.getString("label")); dataModel2.setType1(string2); dataModel2.setMandatory(hierarchicalConfiguration1.getBoolean("mandatory")); dataModel2.setReadOnly(hierarchicalConfiguration1.getBoolean("readOnly")); dataModel2.setVisible(hierarchicalConfiguration1.getBoolean("visible")); switch (string2) { case "bool": case "singleValueText": case "singleValueNumber": case "singleValueDate": case "singleValueDatetime": hierarchicalConfiguration2 = hierarchicalConfiguration1 .configurationAt("state"); dataModel2.setValue1(hierarchicalConfiguration2.getString("value")); break; case "singleSelect": case "singleSelectRadio": case "multiSelect": case "multiSelectCheckbox": hierarchicalConfiguration2 = hierarchicalConfiguration1 .configurationAt("state"); list2 = hierarchicalConfiguration2.configurationsAt("options.option"); if (list2.size() > 0) { listObject3 = new ArrayList<DataModel1>(); for (HierarchicalConfiguration hierarchicalConfiguration3 : list2) { dataModel1 = new DataModel1( hierarchicalConfiguration3.getString("label"), hierarchicalConfiguration3.getString("value")); if (hierarchicalConfiguration3.getBoolean("selected")) { dataModel2.setValue1( hierarchicalConfiguration3.getString("value")); } listObject3.add(dataModel1); } dataModel2.setOptions(listObject3); } break; default: break; } listObject2.add(dataModel2); } } } } break; default: addActionError(String.format("%s %d: %s", getText("Error"), int1, getText(Integer.toString(int1)))); break; } if (httpEntity1 != null) { EntityUtils.consume(httpEntity1); } uriBuilder1.setPath(url1.getPath() + "/rest/resource" + urlString); uri1 = uriBuilder1.build(); httpGet1 = new HttpGet(uri1); httpResponse1 = httpClient1.execute(httpGet1); int2 = httpResponse1.getStatusLine().getStatusCode(); if (int2 == HttpStatus.SC_OK) { httpEntity1 = httpResponse1.getEntity(); inputStream1 = httpEntity1.getContent(); xmlConfiguration = new XMLConfiguration(); xmlConfiguration.load(inputStream1); list1 = xmlConfiguration.configurationsAt("resourceDescriptor"); for (HierarchicalConfiguration hierarchicalConfiguration4 : list1) { if (StringUtils.equalsIgnoreCase( StringUtils.trim(hierarchicalConfiguration4.getString("[@wsType]")), "prop")) { if (map1 == null) map1 = new HashMap<String, String>(); string2 = StringUtils.substringBetween( StringUtils.substringAfter( hierarchicalConfiguration4.getString("[@uriString]"), "_files/"), "_", ".properties"); map1.put(string2, StringUtils.isBlank(string2) ? getText("Default") : getText(string2)); } } } if (httpEntity1 != null) { EntityUtils.consume(httpEntity1); } } } catch (IOException | ConfigurationException | URISyntaxException exception1) { exception1.printStackTrace(); addActionError(exception1.getLocalizedMessage()); httpGet1.abort(); return ERROR; } finally { httpClient1.getConnectionManager().shutdown(); IOUtils.closeQuietly(inputStream1); } break; default: addActionError(getText("This.file.type.is.not.supported")); break; } if (return1 != LOGIN) { sid = new String(Base64.encodeBase64(sid.getBytes())); uid = new String(Base64.encodeBase64(uid.getBytes())); pid = new String(Base64.encodeBase64(pid.getBytes())); } return return1; }
From source file:net.centro.rtb.monitoringcenter.MonitoringCenterServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); boolean disableAuthorization = Boolean.TRUE.toString() .equalsIgnoreCase(servletConfig.getInitParameter(DISABLE_AUTHORIZATION_INIT_PARAM)); if (!disableAuthorization) { String credentials = null; String username = servletConfig.getInitParameter(USERNAME_INIT_PARAM); String password = servletConfig.getInitParameter(PASSWORD_INIT_PARAM); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { credentials = username.trim() + ":" + password.trim(); } else {//from w ww . j ava 2s . c om credentials = DEFAULT_CREDENTIALS; } this.encodedCredentials = BaseEncoding.base64().encode(credentials.getBytes()); } this.objectMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MICROSECONDS, false)) .registerModule(new HealthCheckModule()).setSerializationInclusion(JsonInclude.Include.NON_NULL) .setTimeZone(TimeZone.getDefault()).setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")); this.graphiteMetricFormatter = new GraphiteMetricFormatter(TimeUnit.SECONDS, TimeUnit.MICROSECONDS); try { this.threadDumpGenerator = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError ignore) { } ServletContext servletContext = servletConfig.getServletContext(); String servletSpecVersion = servletContext.getMajorVersion() + "." + servletContext.getMinorVersion(); this.serverInfo = ServerInfo.create(servletContext.getServerInfo(), servletSpecVersion); }
From source file:com.funambol.json.gui.GuiServlet.java
private String doView(HttpServletRequest request) throws Exception { String group = getRequestData(request, GROUP); String key = getRequestData(request, KEY); String result = HTMLManager.getHtmlHeaderFor("Inspecting " + group + " object for key [" + key + "]."); Repository rep = new Repository((String) request.getSession().getAttribute("username"), TimeZone.getDefault(), "UTF-8"); String jsonContent = rep.getContent(group, key); if (jsonContent == null) { throw new Exception(group + " not found for key [" + key + "]."); }/*from w ww . j a va 2 s. c om*/ result += HTMLManager.addTextArea(JSONCONTENT, jsonContent, 80, 30, true); result += HTMLManager.addAction("backForm", "List again", LIST, NameValuePair.parseFromStrings(GROUP, group), ParentTag.OPEN); result += HTMLManager.closePage(buildCommonFooter(request)); return result; }