List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:org.silverpeas.core.web.calendar.ical.ImportIcalManager.java
/** * IMPORT SilverpeasCalendar in Ical format * @param file//from w w w .j a v a 2 s. c o m * @return * @throws Exception */ public String importIcalAgenda(File file) throws Exception { String returnCode = AgendaSessionController.IMPORT_FAILED; InputStreamReader inputStream = null; XmlReader xr = null; try { String charsetUsed = agendaSessionController.getSettings().getString("defaultCharset"); if (isDefined(charset)) { charsetUsed = charset; } // File Encoding detection xr = new XmlReader(file); if (isDefined(xr.getEncoding())) { charsetUsed = xr.getEncoding(); } inputStream = new InputStreamReader(new FileInputStream(file), charsetUsed); CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(inputStream); // Get all EVENTS for (Object o : calendar.getComponents(Component.VEVENT)) { VEvent eventIcal = (VEvent) o; String name = getFieldEvent(eventIcal.getProperty(Property.SUMMARY)); String description = null; if (isDefined(getFieldEvent(eventIcal.getProperty(Property.DESCRIPTION)))) { description = getFieldEvent(eventIcal.getProperty(Property.DESCRIPTION)); } // Name is mandatory in the Silverpeas Agenda if (!isDefined(name)) { if (isDefined(description)) { name = description; } else { name = " "; } } String priority = getFieldEvent(eventIcal.getProperty(Property.PRIORITY)); if (!isDefined(priority)) { priority = Priority.UNDEFINED.getValue(); } String classification = getFieldEvent(eventIcal.getProperty(Property.CLASS)); String startDate = getFieldEvent(eventIcal.getProperty(Property.DTSTART)); String endDate = getFieldEvent(eventIcal.getProperty(Property.DTEND)); Date startDay = getDay(startDate); String startHour = getHour(startDate); Date endDay = getDay(endDate); String endHour = getHour(endDate); // Duration of the event long duration = endDay.getTime() - startDay.getTime(); boolean allDay = false; // All day case // I don't know why ?? if (("00:00".equals(startHour) && "00:00".equals(endHour)) || (!isDefined(startHour) && !isDefined(endHour))) { // For complete Day startHour = ""; endHour = ""; allDay = true; } // Get reccurrent dates Collection reccurenceDates = getRecurrenceDates(eventIcal); // No reccurent dates if (reccurenceDates.isEmpty()) { String idEvent = isExist(eventIcal); // update if event already exists, create if does not exist if (isDefined(idEvent)) { agendaSessionController.updateJournal(idEvent, name, description, priority, classification, startDay, startHour, endDay, endHour); } else { idEvent = agendaSessionController.addJournal(name, description, priority, classification, startDay, startHour, endDay, endHour); } // Get Categories processCategories(eventIcal, idEvent); } else { for (Object reccurenceDate : reccurenceDates) { // Reccurent event startDate startDay = (DateTime) reccurenceDate; // Reccurent event endDate long newEndDay = startDay.getTime() + duration; endDay = new DateTime(newEndDay); if (allDay) { // So we have to convert this date to agenda format date GregorianCalendar gregCalendar = new GregorianCalendar(); gregCalendar.setTime(endDay); gregCalendar.add(GregorianCalendar.DATE, -1); endDay = new Date(gregCalendar.getTime()); } String idEvent = isExist(eventIcal, startDay, endDay, startHour); // update if event already exists, create if does not exist if (isDefined(idEvent)) { agendaSessionController.updateJournal(idEvent, name, description, priority, classification, startDay, startHour, endDay, endHour); } else { idEvent = agendaSessionController.addJournal(name, description, priority, classification, startDay, startHour, endDay, endHour); } // Get Categories processCategories(eventIcal, idEvent); } } } returnCode = AgendaSessionController.IMPORT_SUCCEEDED; } catch (Exception e) { SilverTrace.error("agenda", "ImportIcalManager.importIcalAgenda()", e.getCause().toString()); returnCode = AgendaSessionController.IMPORT_FAILED; } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(xr); } return returnCode; }
From source file:StocksTable5.java
public int retrieveData(final java.util.Date date) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); int year = calendar.get(Calendar.YEAR); final String query = "SELECT data.symbol, symbols.name, " + "data.last, data.open, data.change, data.changeproc, " + "data.volume FROM DATA INNER JOIN SYMBOLS " + "ON DATA.symbol = SYMBOLS.symbol WHERE " + "month(data.date1)=" + month + " AND day(data.date1)=" + day + " AND year(data.date1)=" + year; Thread runner = new Thread() { public void run() { try { // Load the JDBC-ODBC bridge driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:Market", "admin", ""); Statement stmt = conn.createStatement(); ResultSet results = stmt.executeQuery(query); boolean hasData = false; while (results.next()) { if (!hasData) { m_vector.removeAllElements(); hasData = true;/* ww w. j ava2 s . c o m*/ } String symbol = results.getString(1); String name = results.getString(2); double last = results.getDouble(3); double open = results.getDouble(4); double change = results.getDouble(5); double changePr = results.getDouble(6); long volume = results.getLong(7); m_vector.addElement(new StockData(symbol, name, last, open, change, changePr, volume)); } results.close(); stmt.close(); conn.close(); if (!hasData) // We've got nothing m_result = 1; } catch (Exception e) { e.printStackTrace(); System.err.println("Load data error: " + e.toString()); m_result = -1; } m_date = date; Collections.sort(m_vector, new StockComparator(m_sortCol, m_sortAsc)); m_result = 0; } }; runner.start(); return m_result; }
From source file:es.upm.fiware.rss.expenditureLimit.processing.test.ProcessingLimitServiceTest.java
/** * Update periods and check amounts./*from w w w. j av a 2 s .co m*/ */ @Transactional(propagation = Propagation.SUPPORTS) public void checkControls() { DbeTransaction tx = ProcessingLimitServiceTest.generateTransaction(); tx.setTxEndUserId("userIdUpdate"); try { List<DbeExpendControl> controlsBefore = controlService.getExpendDataForUserAppProvCurrency( tx.getTxEndUserId(), tx.getAppProvider().getId().getAggregator().getTxEmail(), tx.getAppProvider().getId().getTxAppProviderId(), tx.getBmCurrency()); Assert.assertNotNull(controlsBefore); // Reset dates to current date--> if not test fail GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DAY_OF_MONTH, 1); for (DbeExpendControl control : controlsBefore) { control.setDtNextPeriodStart(cal.getTime()); controlService.createOrUpdate(control); } limitService.proccesLimit(tx); List<DbeExpendControl> controlsAfter = controlService.getExpendDataForUserAppProvCurrency( tx.getTxEndUserId(), tx.getAppProvider().getId().getAggregator().getTxEmail(), tx.getAppProvider().getId().getTxAppProviderId(), tx.getBmCurrency()); ProcessingLimitServiceTest.logger.debug("Controls:" + controlsAfter.size()); for (DbeExpendControl controlInit : controlsBefore) { for (DbeExpendControl controlEnd : controlsAfter) { if (controlInit.getId().getTxElType().equalsIgnoreCase(controlEnd.getId().getTxElType())) { // All the values without modification Assert.assertTrue( controlInit.getFtExpensedAmount().compareTo(controlEnd.getFtExpensedAmount()) == 0); break; } } } } catch (RSSException e) { ProcessingLimitServiceTest.logger.debug("Error: " + e.getMessage()); Assert.fail("Exception not expected"); } // check error try { tx.setFtChargedAmount(new BigDecimal(1000)); limitService.proccesLimit(tx); Assert.fail("Exception expected"); } catch (RSSException e) { ProcessingLimitServiceTest.logger.debug("Exception received: " + e.getMessage()); // "SVC3705", Assert.assertTrue(e.getMessage().contains("Insufficient payment method balance")); } // check that try { tx.setFtChargedAmount(new BigDecimal(30)); List<DbeExpendControl> controlsBefore = controlService.getExpendDataForUserAppProvCurrency( tx.getTxEndUserId(), tx.getAppProvider().getId().getAggregator().getTxEmail(), tx.getAppProvider().getId().getTxAppProviderId(), tx.getBmCurrency()); // Reset period DbeExpendControl control = controlsBefore.get(0); GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.MONTH, -1); control.setDtNextPeriodStart(cal.getTime()); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); TransactionStatus status = transactionManager.getTransaction(def); controlService.update(control); transactionManager.commit(status); limitService.proccesLimit(tx); List<DbeExpendControl> controlsAfter = controlService.getExpendDataForUserAppProvCurrency( tx.getTxEndUserId(), tx.getAppProvider().getId().getAggregator().getTxEmail(), tx.getAppProvider().getId().getTxAppProviderId(), tx.getBmCurrency()); boolean found = false; for (DbeExpendControl checkControl : controlsAfter) { if (checkControl.getFtExpensedAmount().compareTo(new BigDecimal(0)) == 0) { found = true; break; } } // reset control found Assert.assertTrue(found); } catch (RSSException e) { ProcessingLimitServiceTest.logger.debug("Exception received: " + e.getMessage()); Assert.fail("Exception expected"); } }
From source file:com.sapienter.jbilling.client.payment.PaymentCrudAction.java
@Override protected ForwardAndMessage doSetup() { CreditCardDTO ccDto = null;/*from w w w.j a va 2 s . c om*/ AchDTO achDto = null; PaymentInfoChequeDTO chequeDto = null; boolean isEdit = "edit".equals(request.getParameter("submode")); // if an invoice was selected, pre-populate the amount field InvoiceDTO invoiceDto = (InvoiceDTO) session.getAttribute(Constants.SESSION_INVOICE_DTO); PaymentDTOEx paymentDto = (PaymentDTOEx) session.getAttribute(Constants.SESSION_PAYMENT_DTO); if (invoiceDto != null) { LOG.debug("setting payment with invoice:" + invoiceDto.getId()); myForm.set(FIELD_AMOUNT, invoiceDto.getBalance().toString()); //paypal can't take i18n amounts session.setAttribute("jsp_paypay_amount", invoiceDto.getBalance()); myForm.set(FIELD_CURRENCY, invoiceDto.getCurrency().getId()); } else if (paymentDto != null) { // this works for both refunds and payouts LOG.debug("setting form with payment:" + paymentDto.getId()); myForm.set(FIELD_ID, paymentDto.getId()); myForm.set(FIELD_AMOUNT, paymentDto.getAmount().toString()); setFormDate(FIELD_GROUP_DATE, paymentDto.getPaymentDate()); myForm.set(FIELD_CURRENCY, paymentDto.getCurrency().getId()); ccDto = paymentDto.getCreditCard(); achDto = paymentDto.getAch(); chequeDto = paymentDto.getCheque(); } else { // this is not an invoice selected, it's the first call LOG.debug("setting payment without invoice"); // the date might come handy setFormDate(FIELD_GROUP_DATE, Calendar.getInstance().getTime()); // make the default real-time myForm.set(FIELD_PROCESS_NOW, new Boolean(true)); // find out if this is a payment or a refund } boolean isRefund = session.getAttribute("jsp_is_refund") != null; // populate the credit card fields with the cc in file // if this is a payment creation only if (!isRefund && !isEdit && ((String) myForm.get(FIELD_CC_NUMBER)).length() == 0) { // normal payment, get the selected user cc // if the user has a credit card, put it (this is a waste for // cheques, but it really doesn't hurt) LOG.debug("getting this user's cc"); UserDTOEx user = getSessionUser(); ccDto = user.getCreditCard(); achDto = user.getAch(); } if (ccDto != null) { String ccNumber = ccDto.getNumber(); // mask cc number ccNumber = maskCreditCard(ccNumber); myForm.set(FIELD_CC_NUMBER, ccNumber); myForm.set(FIELD_CC_NAME, ccDto.getName()); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(ccDto.getCcExpiry()); myForm.set(FIELD_GROUP_CC_EXPIRY + "_month", String.valueOf(cal.get(GregorianCalendar.MONTH) + 1)); myForm.set(FIELD_GROUP_CC_EXPIRY + "_year", String.valueOf(cal.get(GregorianCalendar.YEAR))); } if (achDto != null) { myForm.set(FIELD_ACH_ABA_CODE, achDto.getAbaRouting()); myForm.set(FIELD_ACH_ACCOUNT_NUMBER, achDto.getBankAccount()); myForm.set(FIELD_ACH_BANK_NAME, achDto.getBankName()); myForm.set(FIELD_ACH_ACCOUNT_NAME, achDto.getAccountName()); myForm.set(FIELD_ACH_ACCOUNT_TYPE, achDto.getAccountType()); } if (chequeDto != null) { myForm.set(FIELD_CHEQUE_BANK, chequeDto.getBank()); myForm.set(FIELD_CHEQUE_NUMBER, chequeDto.getNumber()); setFormDate(FIELD_GROUP_CHEQUE_DATE, chequeDto.getDate()); } ForwardAndMessage result = new ForwardAndMessage(FORWARD_EDIT); // if this payment is direct from an order, continue with the // page without invoice list if (request.getParameter("direct") != null) { // the date won't be shown, and it has to be initialized setFormDate(FIELD_GROUP_DATE, Calendar.getInstance().getTime()); myForm.set(FIELD_PAY_METHOD, "cc"); result = new ForwardAndMessage(FORWARD_FROM_ORDER, MESSAGE_INVOICE_GENERATED); } // if this is a payout, it has its own page if (request.getParameter("payout") != null) { result = new ForwardAndMessage(FORWARD_PAYOUT); } // payment edition has a different layout if (isEdit) { result = new ForwardAndMessage(FORWARD_UPDATE); } return result; }
From source file:org.webical.test.web.component.MonthViewPanelTest.java
/** * Test rendering of the panel without events. *///from w w w. j ava 2s . c om public void testRenderingWithoutEvents() { log.debug("testRenderingWithoutEvents"); // Add an EventManager annotApplicationContextMock.putBean("eventManager", new MockEventManager()); final GregorianCalendar currentDate = CalendarUtils.newTodayCalendar(getFirstDayOfWeek()); // render start page with a MonthViewPanel wicketTester.startPage(new ITestPageSource() { private static final long serialVersionUID = 1L; public Page getTestPage() { return new PanelTestPage(new MonthViewPanel(PanelTestPage.PANEL_MARKUP_ID, 1, currentDate) { private static final long serialVersionUID = 1L; @Override public void onAction(IAction action) { /* NOTHING TO DO */ } }); } }); // Basic Assertions wicketTester.assertRenderedPage(PanelTestPage.class); wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID, MonthViewPanel.class); // Weekday headers wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID + ":monthHeaderRepeater", RepeatingView.class); DateFormat dateFormat = new SimpleDateFormat("E", getTestSession().getLocale()); GregorianCalendar weekCal = CalendarUtils.duplicateCalendar(currentDate); weekCal.setTime(CalendarUtils.getFirstDayOfWeek(currentDate.getTime(), getFirstDayOfWeek())); for (int i = 0; i < 7; ++i) { wicketTester.assertLabel(PanelTestPage.PANEL_MARKUP_ID + ":monthHeaderRepeater:headerDay" + i, dateFormat.format(weekCal.getTime())); weekCal.add(GregorianCalendar.DAY_OF_WEEK, 1); } // Set the correct dates to find the first and last day of the month GregorianCalendar monthFirstDayDate = CalendarUtils.duplicateCalendar(currentDate); monthFirstDayDate .setTime(CalendarUtils.getFirstDayOfWeekOfMonth(currentDate.getTime(), getFirstDayOfWeek())); log.debug("testRenderingWithoutEvents:monthFirstDayDate " + monthFirstDayDate.getTime()); // Assert the first day in the view wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthFirstDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthFirstDayDate.get(GregorianCalendar.DAY_OF_YEAR), MonthDayPanel.class); GregorianCalendar monthLastDayDate = CalendarUtils.duplicateCalendar(currentDate); monthLastDayDate.setTime(CalendarUtils.getLastWeekDayOfMonth(currentDate.getTime(), getFirstDayOfWeek())); log.debug("testRenderingWithoutEvents:monthLastDayDate " + monthLastDayDate.getTime()); // Assert the last day in the view wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthLastDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthLastDayDate.get(GregorianCalendar.DAY_OF_YEAR), MonthDayPanel.class); }
From source file:fr.paris.lutece.plugins.document.modules.solr.indexer.SolrDocIndexer.java
/** * Get item//from ww w . j av a 2 s . co m * @param portlet The portlet * @param document The document * @return The item * @throws IOException */ private SolrItem getItem(Portlet portlet, Document document) throws IOException { // the item SolrItem item = new SolrItem(); item.setUid(getResourceUid(Integer.valueOf(document.getId()).toString(), DocumentIndexerUtils.CONSTANT_TYPE_RESOURCE)); item.setDate(document.getDateModification()); item.setType(document.getType()); item.setSummary(document.getSummary()); item.setTitle(document.getTitle()); item.setSite(SolrIndexerService.getWebAppName()); item.setRole("none"); if (portlet != null) { item.setDocPortletId(document.getId() + SolrConstants.CONSTANT_AND + portlet.getId()); } item.setXmlContent(document.getXmlValidatedContent()); // Reload the full object to get all its searchable attributes UrlItem url = new UrlItem(SolrIndexerService.getBaseUrl()); url.addParameter(PARAMETER_DOCUMENT_ID, document.getId()); url.addParameter(PARAMETER_PORTLET_ID, portlet.getId()); item.setUrl(url.getUrl()); // Date Hierarchy GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(document.getDateModification()); item.setHieDate(calendar.get(GregorianCalendar.YEAR) + "/" + (calendar.get(GregorianCalendar.MONTH) + 1) + "/" + calendar.get(GregorianCalendar.DAY_OF_MONTH) + "/"); List<String> categorie = new ArrayList<String>(); for (Category cat : document.getCategories()) { categorie.add(cat.getName()); } item.setCategorie(categorie); // The content String strContentToIndex = getContentToIndex(document, item); ContentHandler handler = null; if (PARAMETER_DOCUMENT_MAX_CHARS != null) { handler = new BodyContentHandler(PARAMETER_DOCUMENT_MAX_CHARS); } else { handler = new BodyContentHandler(); } Metadata metadata = new Metadata(); try { new HtmlParser().parse(new ByteArrayInputStream(strContentToIndex.getBytes()), handler, metadata, new ParseContext()); } catch (SAXException e) { throw new AppException("Error during document parsing."); } catch (TikaException e) { throw new AppException("Error during document parsing."); } item.setContent(handler.toString()); return item; }
From source file:oracle.retail.stores.pos.ado.utility.Utility.java
/** * This method checks if the entered expiry date of ID is valid. Returns false * if entered expiry date is before the current date. True otherwise. * @param expirationDate/*from w ww. jav a2 s .c om*/ * @throws TenderException if not a valid expiration date */ public boolean isValidExpirationDate(String expirationDate) throws TenderException { boolean result = true; Date today = new Date(); EYSDate todayEYS = new EYSDate(today); String format = EYSDate.ID_EXPIRATION_DATE_FORMAT; Locale locale = LocaleMap.getLocale(LocaleConstantsIfc.DEFAULT_LOCALE); DateFormat dateFormat = new SimpleDateFormat(format, locale); Date date = null; EYSDate dateEYS = null; try { date = dateFormat.parse(expirationDate); dateEYS = new EYSDate(date); } catch (ParseException e) { throw new TenderException("Invalid expiration date format", TenderErrorCodeEnum.INVALID_EXPIRATION_DATE, e); } GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance(); gc.setTime(today); int thisMonth = gc.get(Calendar.MONTH); int thisYear = gc.get(Calendar.YEAR); gc.clear(); Calendar c = dateEYS.calendarValue(); gc.setTime(c.getTime()); if (dateEYS.before(todayEYS) && !((thisMonth == gc.get(Calendar.MONTH)) && (thisYear == gc.get(Calendar.YEAR)))) { result = false; } return result; }
From source file:TimePeriod.java
/** * Gibt zurck, wie oft der bergebene Wochentag im Zeitraum vorkommt. * /*from w w w . j a v a2 s .c o m*/ * @param wochentag * Sonntag = 1 * @return */ public int getNumberOfWeekdays(int wochentag) { int ergebnis = 0; GregorianCalendar temp = new GregorianCalendar(); temp.setTime(from.getTime()); // Schleife ber alle Tage int aktuellerTag; while (temp.before(to)) { aktuellerTag = temp.get(Calendar.DAY_OF_WEEK); if (aktuellerTag == wochentag) ergebnis++; temp.setTimeInMillis(temp.getTimeInMillis() + ONE_DAY); } return ergebnis; }
From source file:nl.minbzk.dwr.zoeken.enricher.uploader.ElasticSearchResultUploader.java
/** * Determine the database name, based on the composite key, or null if any of the composite key replacements could not be resolved. * //from w w w. j a v a2 s . c o m * XXX: We only consider the replacement values from the first document given. * * @param name * @param nameComposition * @param namePrerequisitesExpression * @param documents * @return String */ private String determineAlternateDatabaseName(final String name, final String nameComposition, final String namePrerequisitesExpression, final List<Map<String, Object>> documents) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); String result; result = nameComposition.replace("{name}", name).trim(); result = result.replace("{year}", format("%04d", calendar.get(calendar.YEAR))); result = result.replace("{month}", format("%02d", calendar.get(calendar.MONTH))); if (documents.size() > 0) { final Map<String, Object> document = documents.get(0); while (result.contains("{") && result.indexOf("}") > result.indexOf("{")) { String fieldName = result.substring(result.indexOf("{") + 1, result.indexOf("}")); if (document.containsKey(fieldName) && !document.get(fieldName).getClass().isArray()) result = result.replace("{" + fieldName + "}", document.get(fieldName).toString()); else { if (logger.isDebugEnabled()) logger.debug(format( "Field '%s' was missing from document with ID '%s' - will revert back to default collection '%s'", fieldName, getReference(document), name)); return null; } } // Also check the pre-requisite expression - only return a composite database name if it's met if (StringUtils.hasText(namePrerequisitesExpression)) { ExpressionParser parser = new SpelExpressionParser(); final Map<String, Object> values = new HashMap<String, Object>(); // XXX: Always get just the first value for (Map.Entry<String, Object> entry : document.entrySet()) if (entry.getValue().getClass().isArray()) values.put(entry.getKey(), ((Object[]) entry.getValue())[0]); else if (entry.getValue() instanceof List) values.put(entry.getKey(), ((List<Object>) entry.getValue()).get(0)); else values.put(entry.getKey(), entry.getValue()); StandardEvaluationContext context = new StandardEvaluationContext(new Object() { public Map<String, Object> getValues() { return values; } }); if (!parser.parseExpression(namePrerequisitesExpression).getValue(context, Boolean.class)) { if (logger.isDebugEnabled()) logger.debug(format( "Pre-requisite expression '%s' failed to match against document with ID '%s' - will revert back to default collection '%s'", namePrerequisitesExpression, getReference(document), name)); return null; } } } return result; }
From source file:org.overlord.dtgov.taskapi.TaskApi.java
/** * Fetches a single task by its unique ID. * @param httpRequest//from ww w . j a va2 s .co m * @param taskId * @throws Exception */ @GET @Path("get/{taskId}") @Produces(MediaType.APPLICATION_XML) public TaskType getTask(@Context HttpServletRequest httpRequest, @PathParam("taskId") long taskId) throws Exception { assertCurrentUser(httpRequest); Task task = taskService.getTaskById(taskId); TaskType rval = new TaskType(); List<I18NText> descriptions = task.getDescriptions(); if (descriptions != null && !descriptions.isEmpty()) { rval.setDescription(descriptions.iterator().next().getText()); } List<I18NText> names = task.getNames(); if (names != null && !names.isEmpty()) { rval.setName(names.iterator().next().getText()); } rval.setPriority(task.getPriority()); rval.setId(String.valueOf(task.getId())); rval.setType(task.getTaskType()); TaskData taskData = task.getTaskData(); if (taskData != null) { User owner = taskData.getActualOwner(); if (owner != null) { rval.setOwner(owner.getId()); } Date expTime = taskData.getExpirationTime(); if (expTime != null) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(expTime); DatatypeFactory dtFactory = DatatypeFactory.newInstance(); rval.setDueDate(dtFactory.newXMLGregorianCalendar(cal)); } rval.setStatus(StatusType.fromValue(taskData.getStatus().toString())); } long docId = taskService.getTaskById(taskId).getTaskData().getDocumentContentId(); if (docId > 0) { //Set the input params Content content = taskService.getContentById(docId); @SuppressWarnings("unchecked") Map<String, Object> inputParams = (Map<String, Object>) ContentMarshallerHelper .unmarshall(content.getContent(), null); if (inputParams != null && inputParams.size() > 0) { if (rval.getTaskData() == null) rval.setTaskData(new TaskDataType()); for (String key : inputParams.keySet()) { Entry entry = new Entry(); entry.setKey(key); entry.setValue(String.valueOf(inputParams.get(key))); rval.getTaskData().getEntry().add(entry); } } } return rval; }