/** * Retrieving Data as String */ public String getICalDataAsString() { return icsCalendar.toString(); } }
private void encodeAndTransmitResponse(HttpServletResponse httpServletResponse, Calendar calendar) throws Exception { httpServletResponse.setHeader("Content-Type", "text/calendar; charset=" + CharEncoding.UTF_8); final OutputStream outputStream = httpServletResponse.getOutputStream(); outputStream.write(calendar.toString().getBytes(CharEncoding.UTF_8)); outputStream.close(); } }
@Override @SuppressWarnings("unchecked") public <X> X unwrap(Calendar value, Class<X> type, WrapperOptions options) { if (value == null) { return null; } if (Calendar.class.isAssignableFrom(type)) { return (X) value; } if (CharacterStream.class.isAssignableFrom(type)) { return (X) new CharacterStreamImpl(value.toString()); } throw unknownUnwrap(type); }
@Override @SuppressWarnings("unchecked") public <X> X unwrap(Calendar value, Class<X> type, WrapperOptions options) { if (value == null) { return null; } if (Calendar.class.isAssignableFrom(type)) { return (X) value; } if (CharacterStream.class.isAssignableFrom(type)) { return (X) new CharacterStreamImpl(value.toString()); } throw unknownUnwrap(type); }
private String readCalendarData(DavCalendarResource resource) throws CosmoDavException { if (! resource.exists()) { return null; } StringBuilder builder = new StringBuilder(); if (outputFilter != null) { outputFilter.filter(resource.getCalendar(), builder); } else { builder.append(resource.getCalendar().toString()); } return builder.toString(); } }
private String readCalendarData(DavCalendarResource resource) throws CosmoDavException { if (! resource.exists()) { return null; } StringBuilder builder = new StringBuilder(); if (outputFilter != null) { outputFilter.filter(resource.getCalendar(), builder); } else { builder.append(resource.getCalendar().toString()); } return builder.toString(); } }
public Calendar deepCopyNotNull(Calendar value) { String representation; try { representation = value.toString(); return new CalendarBuilder().build(new StringReader(representation)); } catch (IOException e) { throw new CosmoIOException(e); } catch (ParserException e) { throw new CosmoParseException(e); } } }
public Calendar deepCopyNotNull(Calendar value) { String representation; try { representation = value.toString(); return new CalendarBuilder().build(new StringReader(representation)); } catch (IOException e) { throw new CosmoIOException(e); } catch (ParserException e) { throw new CosmoParseException(e); } } }
/** * @param filename * @return */ private net.fortuna.ical4j.model.Calendar loadCalendar(String resourceString) throws IOException, ParserException, ValidationException { net.fortuna.ical4j.model.Calendar calendar = Calendars.load( getClass().getResource(resourceString)); calendar.validate(); log.info("Resource: " + resourceString); if (log.isDebugEnabled()) { log.debug("Calendar:\n=========\n" + calendar.toString()); } return calendar; }
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); try { byte[] calendarBytes = getCalendar().toString().getBytes("UTF-8"); properties.add(new ContentLength(Long.valueOf(calendarBytes.length))); } catch (Exception e) { throw new CosmoException("Can't convert calendar", e); } properties.add(new ContentType(ICALENDAR_MEDIA_TYPE, "UTF-8")); }
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); try { byte[] calendarBytes = getCalendar().toString().getBytes("UTF-8"); properties.add(new ContentLength(Long.valueOf(calendarBytes.length))); } catch (Exception e) { throw new CosmoException("Can't convert calendar", e); } properties.add(new ContentType(ICALENDAR_MEDIA_TYPE, "UTF-8")); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } try (FoldingWriter writer = new FoldingWriter(out, foldLength)) { writer.write(calendar.toString()); } } }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } try (FoldingWriter writer = new FoldingWriter(out, foldLength)) { writer.write(calendar.toString()); } } }
/** * */ public void testCreateDefinition() { Calendar calendar = new Calendar(); calendar.getComponents().add(tz); log.info(calendar.toString()); }
public void testVAvailability() throws ParserException, IOException { CalendarBuilder calendarBuilder = new CalendarBuilder(); String availability = getVAvailabilityICal(); Reader reader = new StringReader(availability); Calendar calendar = calendarBuilder.build(reader); Component availabilityComponent = calendar.getComponent(Component.VAVAILABILITY); Assert.assertNotNull(availabilityComponent); Assert.assertFalse(((VAvailability) availabilityComponent).getAvailable().isEmpty()); String iCalString = calendar.toString(); Assert.assertTrue(iCalString.contains("BEGIN:AVAILABLE")); Assert.assertEquals(iCalString.trim(), availability); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }
private void writeContentOnResponse(DavRequest request, DavResponse response, WebDavResource resource) throws IOException { // strip the content if there's a ticket with free-busy access if (!(resource instanceof DavCalendarCollection)) { throw new IllegalStateException("Incompatible resource type for this provider"); } DavCalendarCollection davCollection = DavCalendarCollection.class.cast(resource); CollectionItem collectionItem = (CollectionItem) davCollection.getItem(); Calendar result = getCalendarFromCollection(request, collectionItem); Ticket contextTicket = getSecurityContext().getTicket(); Set<Ticket> collectionTickets = collectionItem.getTickets(); if (contextTicket != null && collectionTickets != null) { if (collectionTickets.contains(contextTicket) && contextTicket.isFreeBusy()) { result = FreeBusyUtil.getFreeBusyCalendar(result, this.productId); } } response.setHeader("ETag", "\""+ resource.getETag() +"\""); response.setContentType(ICALENDAR_MEDIA_TYPE); response.setCharacterEncoding(CHARSET_UTF8); response.getWriter().write(result.toString()); response.flushBuffer(); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } final FoldingWriter writer = new FoldingWriter(out, foldLength); try { writer.write(calendar.toString()); } finally { writer.close(); } } }
@Test public void shouldSetTimezoneToUtcForNoTZdescription() { String actualCalendar = "outlook/TZ-no-description.txt"; try { Calendar actual = buildCalendar(actualCalendar); actual = transformer.transform(actual); Calendar expected = buildCalendar("outlook/TZ-set-to-utc.txt"); assertEquals(expected.toString(), actual.toString()); assertEquals(expected, actual); } catch (Exception e) { e.printStackTrace(); fail("RFC transformation failed for " + actualCalendar); } }