net.fortuna.ical4j.data.ParserException Java Examples

The following examples show how to use net.fortuna.ical4j.data.ParserException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventCollectionResource.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
private String extractUid(String icalendar) throws IOException, ParserException {
    
    String uid = null;
    StringReader reader = new StringReader(icalendar);
    CalendarBuilder builder = new CalendarBuilder();
    Calendar calendar = builder.build(new UnfoldingReader(reader, true));
    if ( calendar != null && calendar.getComponents() != null ) {
        Iterator<Component> iterator = calendar.getComponents().iterator();
        while (iterator.hasNext()) {
            Component component = iterator.next();
            if ( component instanceof VEvent ) {
                uid = ((VEvent)component).getUid().getValue();
                break;
            }
        }
    }
    
    return uid;
}
 
Example #2
Source File: ICalendarService.java    From axelor-open-suite with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Load the calendar events from the given reader.
 *
 * @param calendar the target {@link ICalendar}
 * @param reader the input source reader
 * @throws IOException
 * @throws ParserException
 */
@Transactional(rollbackOn = {Exception.class})
public void load(ICalendar calendar, Reader reader) throws IOException, ParserException {
  Preconditions.checkNotNull(calendar, "calendar can't be null");
  Preconditions.checkNotNull(reader, "reader can't be null");

  final CalendarBuilder builder = new CalendarBuilder();
  final Calendar cal = builder.build(reader);

  if (calendar.getName() == null && cal.getProperty(X_WR_CALNAME) != null) {
    calendar.setName(cal.getProperty(X_WR_CALNAME).getValue());
  }

  for (Object item : cal.getComponents(Component.VEVENT)) {
    findOrCreateEvent((VEvent) item, calendar);
  }
}
 
Example #3
Source File: ICalendarController.java    From axelor-open-suite with GNU Affero General Public License v3.0 6 votes vote down vote up
public void importCalendarFile(ActionRequest request, ActionResponse response)
    throws IOException, ParserException {

  ImportConfiguration imp = request.getContext().asType(ImportConfiguration.class);
  Object object = request.getContext().get("_id");
  ICalendar cal = null;
  if (object != null) {
    Long id = Long.valueOf(object.toString());
    cal = Beans.get(ICalendarRepository.class).find(id);
  }

  if (cal == null) {
    cal = new ICalendar();
  }
  File data = MetaFiles.getPath(imp.getDataMetaFile()).toFile();
  Beans.get(ICalendarService.class).load(cal, data);
  response.setCanClose(true);
  response.setReload(true);
}
 
Example #4
Source File: HibICalendarAttribute.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public void setValue(String value) {
    try {
        this.value = CalendarUtils.parseCalendar(value);
    } catch (ParserException e) {
        throw new ModelValidationException("invalid calendar: " + value);
    } catch (IOException ioe) {
        throw new ModelValidationException("error parsing calendar");
    }
}
 
Example #5
Source File: EventCollectionResource.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
/**
 * Formats a list of events as a JSON array.
 * 
 * @param events
 * @param uriInfo
 * @return
 * @throws JsonException
 * @throws IOException
 */
private String createJsonArray(String eventString, UriInfo uriInfo) 
                    throws ParserException, IOException {

    StringReader reader = new StringReader(eventString);
    StringBuilder sb = new StringBuilder();
    CalendarParser parser = CalendarParserFactory.getInstance().createParser();
    URI baseURI = UriHelper.copy(uriInfo.getAbsolutePath(),CalendarService.isUseRelativeUrls());
    baseURI = CalendarService.adaptUriToScn(baseURI);
    parser.parse(new UnfoldingReader(reader, true), new JsonCalendarGenerator(sb, baseURI, false));

    return sb.toString();
}
 
Example #6
Source File: ICalendarService.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Load the calendar events from the given source file.
 *
 * @param calendar the target {@link ICalendar}
 * @param file the input file
 * @throws IOException
 * @throws ParserException
 */
@Transactional(rollbackOn = {Exception.class})
public void load(ICalendar calendar, File file) throws IOException, ParserException {
  Preconditions.checkNotNull(calendar, "calendar can't be null");
  Preconditions.checkNotNull(file, "input file can't be null");
  Preconditions.checkArgument(file.exists(), "no such file: " + file);

  final Reader reader = new FileReader(file);
  try {
    load(calendar, reader);
  } finally {
    reader.close();
  }
}
 
Example #7
Source File: ICalendarService.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Load the calendar events from the given source.
 *
 * @param calendar the target {@link ICalendar}
 * @param text the raw calendar text
 * @throws ParserException
 */
@Transactional(rollbackOn = {Exception.class})
public void load(ICalendar calendar, String text) throws ParserException {
  Preconditions.checkNotNull(calendar, "calendar can't be null");
  Preconditions.checkNotNull(text, "calendar source can't be null");
  final StringReader reader = new StringReader(text);
  try {
    load(calendar, reader);
  } catch (IOException e) {
  }
}
 
Example #8
Source File: CalendarClientsAdapterTest.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * MKCALENDAR in icalIOS7 provides a timezone without prodid
 * @throws IOException
 * @throws ParserException
 * @throws ValidationException
 */
@Test
public void icalIOS7_missingTimezoneProductIdIsAdded() throws IOException, ParserException, ValidationException{
    Calendar calendar = new CalendarBuilder().build(new ByteArrayInputStream(geticalIOS7Calendar()));
    CalendarClientsAdapter.adaptTimezoneCalendarComponent(calendar);
    calendar.validate(true);//must not throw exceptions
}
 
Example #9
Source File: MockICalendarAttribute.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Sets value.
 * @param is The input stream.
 */
public void setValue(InputStream is) {
    try {
        this.value = CalendarUtils.parseCalendar(is);
    } catch (ParserException e) {
        throw new ModelValidationException("invalid calendar: "
                + e.getMessage());
    } catch (IOException ioe) {
        throw new ModelValidationException("error parsing calendar: "
                + ioe.getMessage());
    }
}
 
Example #10
Source File: MockICalendarAttribute.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Sets value.
 * @param value The value.
 */
public void setValue(String value) {
    try {
        this.value = CalendarUtils.parseCalendar(value);
    } catch (ParserException e) {
        throw new ModelValidationException("invalid calendar: " + value);
    } catch (IOException ioe) {
        throw new ModelValidationException("error parsing calendar");
    }
}
 
Example #11
Source File: HibICalendarAttribute.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public void setValue(InputStream is) {
    try {
        this.value = CalendarUtils.parseCalendar(is);
    } catch (ParserException e) {
        throw new ModelValidationException("invalid calendar: "
                + e.getMessage());
    } catch (IOException ioe) {
        throw new ModelValidationException("error parsing calendar: "
                + ioe.getMessage());
    }
}
 
Example #12
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Builds event.
 * @param element The element.
 * @param handler The content handler.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private void buildEvent(Element element, ContentHandler handler) throws ParserException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Building event");
    }

    handler.startComponent(Component.VEVENT);

    buildProperty(findElement(XPATH_DTSTART, element), Property.DTSTART, handler);
    buildProperty(findElement(XPATH_DTEND, element), Property.DTEND, handler);
    buildProperty(findElement(XPATH_DURATION, element), Property.DURATION, handler);
    buildProperty(findElement(XPATH_SUMMARY, element), Property.SUMMARY, handler);
    buildProperty(findElement(XPATH_UID, element), Property.UID, handler);
    buildProperty(findElement(XPATH_DTSTAMP, element), Property.DTSTAMP, handler);
    for (Element category : findElements(XPATH_CATEGORY, element)) {
        buildProperty(category, Property.CATEGORIES, handler);
    }
    buildProperty(findElement(XPATH_LOCATION, element), Property.LOCATION, handler);
    buildProperty(findElement(XPATH_URL, element), Property.URL, handler);
    buildProperty(findElement(XPATH_DESCRIPTION, element), Property.DESCRIPTION, handler);
    buildProperty(findElement(XPATH_LAST_MODIFIED, element), Property.LAST_MODIFIED, handler);
    buildProperty(findElement(XPATH_STATUS, element), Property.STATUS, handler);
    buildProperty(findElement(XPATH_CLASS, element), Property.CLASS, handler);
    for (Element attendee : findElements(XPATH_ATTENDEE, element)) {
        buildProperty(attendee, Property.ATTENDEE, handler);
    }
    buildProperty(findElement(XPATH_CONTACT, element), Property.CONTACT, handler);
    buildProperty(findElement(XPATH_ORGANIZER, element), Property.ORGANIZER, handler);

    handler.endComponent(Component.VEVENT);
}
 
Example #13
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets text content.
 * @param element The element.
 * @return The content.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private static String getTextContent(Element element)
    throws ParserException {
    try {
        return element.getTextContent().trim().replaceAll("\\s+", " ");
    } catch (DOMException e) {
        throw new ParserException("Unable to get text content for element " + element.getNodeName(), -1, e);
    }
}
 
Example #14
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Finds element.
 * @param expr The XPath expression.
 * @param context The object context.
 * @return The element.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private static Element findElement(XPathExpression expr, Object context)  throws ParserException {
    Node n = findNode(expr, context);
    if (n == null || ! (n instanceof Element)) {
        return null;
    }
    return (Element) n;
}
 
Example #15
Source File: CalendarUtils.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
    * Parse icalendar string into calendar component
    * 
    * @param calendar
    *            icalendar string
    * @return Component object
    * @throws ParserException
    *             - if something is wrong this exception is thrown.
    * @throws IOException
    *             - if something is wrong this exception is thrown.
    */
   public static Component parseComponent(String component) throws ParserException, IOException {
if (component == null) {
    return null;
}
/*
 * Don't use dispenser as this method may be called from within a build() as in the case of the custom timezone
 * registry parsing a timezone
 */
CalendarBuilder builder = new CalendarBuilder();
StringReader sr = new StringReader("BEGIN:VCALENDAR\n" + component + "END:VCALENDAR");

return (Component) conformToRfc5545(builder.build(sr)).getComponents().get(0);
   }
 
Example #16
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Finds element.
 * @param expr The XPath expression.
 * @param context The context object.
 * @return The list.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private static List<Element> findElements(XPathExpression expr, Object context) throws ParserException {
    NodeList nodes = findNodes(expr, context);
    ArrayList<Element> elements = new ArrayList<Element>();
    for (int i=0; i<nodes.getLength(); i++) {
        Node n = nodes.item(i);
        if (n instanceof Element) {
            elements.add((Element) n);
        }
    }
    return elements;
}
 
Example #17
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Finds nodes.
 * @param expr The XPath expression.
 * @param context The context object.
 * @return The node.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private static Node findNode(XPathExpression expr, Object context) throws ParserException {
    try {
        return (Node) expr.evaluate(context, XPathConstants.NODE);
    } catch (XPathException e) {
        throw new ParserException("Unable to find node", -1, e);
    }
}
 
Example #18
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Finds nodes.
 * @param expr The XPath Expression.
 * @param context The context object.
 * @return The node list.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private static NodeList findNodes(XPathExpression expr, Object context) throws ParserException {
    try {
        return (NodeList) expr.evaluate(context, XPathConstants.NODESET);
    } catch (XPathException e) {
        throw new ParserException("Unable to find nodes", -1, e);
    }
}
 
Example #19
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Builds calendar.
 * @param d The document.
 * @param handler The content handler.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
private void buildCalendar(Document d, ContentHandler handler) throws ParserException {
    // "The root class name for hCalendar is "vcalendar". An element with a
    // class name of "vcalendar" is itself called an hCalendar.
    //
    // The root class name for events is "vevent". An element with a class
    // name of "vevent" is itself called an hCalender event.
    //
    // For authoring convenience, both "vevent" and "vcalendar" are
    // treated as root class names for parsing purposes. If a document
    // contains elements with class name "vevent" but not "vcalendar", the
    // entire document has an implied "vcalendar" context."

    // XXX: We assume that the entire document has a single vcalendar
    // context. It is possible that the document contains more than one
    // vcalendar element. In this case, we should probably only process
    // that element and log a warning about skipping the others.

    if (LOG.isDebugEnabled()) {
        LOG.debug("Building calendar");
    }

    handler.startCalendar();

    // no PRODID, as the using application should set that itself

    handler.startProperty(Property.VERSION);
    try {
        handler.propertyValue(Version.VERSION_2_0.getValue());
    } catch (URISyntaxException | ParseException | IOException e) {
        LOG.warn("", e);
    } 
    handler.endProperty(Property.VERSION);

    for (Element vevent : findElements(XPATH_VEVENTS, d)) {
        buildEvent(vevent, handler);
    }

    // XXX: support other "first class components": vjournal, vtodo,
    // vfreebusy, vavailability, vvenue

    handler.endCalendar();
}
 
Example #20
Source File: ContextServiceExtensionsAdviceTest.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param user 
 * @return ContentItem 
 * @throws ParserException 
 * @throws IOException 
 */
private ContentItem createContentItemManyAttendees(User user) throws ParserException, IOException{
    String calendarContent =
            "BEGIN:VCALENDAR\n" +
                "CALSCALE:GREGORIAN\n" +
                "PRODID:-//Example Inc.//Example Calendar//EN\n" +
                "VERSION:2.0\n" +
                "BEGIN:VTIMEZONE\n" +
                "LAST-MODIFIED:20040110T032845Z\n" +
                "TZID:US/Eastern\n" +
                "BEGIN:DAYLIGHT\n" +
                "DTSTART:20000404T020000\n" +
                "RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4\n" +
                "TZNAME:EDT\n" +
                "TZOFFSETFROM:-0500\n" +
                "TZOFFSETTO:-0400\n" +
                "END:DAYLIGHT\n" +
                "BEGIN:STANDARD\n" +
                "DTSTART:20001026T020000\n" +
                "RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\n" +
                "TZNAME:EST\n" +
                "TZOFFSETFROM:-0400\n" +
                "TZOFFSETTO:-0500\n" +
                "END:STANDARD\n" +
                "END:VTIMEZONE\n" +
                "BEGIN:VEVENT\n" +
                "ATTENDEE;CN=Attendee Attendee;PARTSTAT=ACCEPTED:mailto:[email protected]\n" +
                "ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:[email protected]\n" +
                "ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:[email protected]\n" +
                "DTSTAMP:20051228T232640Z\n" +
                "DTSTART;TZID=US/Eastern:20060109T111500\n" +
                "DURATION:PT1H\n" +
                "ORGANIZER;CN=\"Bernard Desruisseaux\":mailto:[email protected]\n" +
                "SUMMARY:Meeting 1.3\n" +
                "UID:[email protected]\n" +
                "END:VEVENT\n" +
                "END:VCALENDAR";
    
    Calendar calendar = CalendarUtils.parseCalendar(calendarContent);
     
    
    //call service
    ContentItem contentItem = testHelper.makeDummyContent(user);


    HibEventStamp eventStamp = new HibEventStamp();
        
    eventStamp.setEventCalendar(calendar);        
    contentItem.addStamp(eventStamp);
    return contentItem;
}
 
Example #21
Source File: ContextServiceExtensionsAdviceTest.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @throws IOException 
 * @throws ValidationException 
 * @throws URISyntaxException  
 * @throws ParserException  
 */
@Test
public void testContentItemManyAttendees() throws IOException, ValidationException, URISyntaxException, ParserException{
    createProxyServiceWithExpectedAdviceExecution();
    addCheckManyAttendeedCallExpectedOnHandlers();
    
    User user = testHelper.makeDummyUser("user1", "password");

    CollectionItem rootCollection = contentDao.createRootItem(user);
    
    ContentItem contentItem = createContentItemManyAttendees(user);
    
    Set<ContentItem> contentItems = new HashSet<ContentItem>();
    contentItems.add(contentItem);
    
    
    
    proxyService.createContentItems(rootCollection, contentItems);
    
    proxyService.updateContent(contentItem);
    
    proxyService.removeContent(contentItem);
}
 
Example #22
Source File: SimpleUrlContentReader.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Gets and validates the content from the specified <code>url</code>.
 * 
 * @param url
 *            <code>URL</code> where to get the content from.
 * @param timeout
 *            maximum time to wait before abandoning the connection in milliseconds
 * @param headersMap
 *            headers to be sent when making the request to the specified URL
 * @return content read from the specified <code>url</code>
 */
public Set<NoteItem> getContent(String url, int timeoutInMillis, RequestOptions options) {
    CloseableHttpClient client = null;
    CloseableHttpResponse response = null;
    try {
        URL source = build(url, options);
        HttpGet request = new HttpGet(source.toURI());
        for (Entry<String, String> entry : options.headers().entrySet()) {
            request.addHeader(entry.getKey(), entry.getValue());
        }

        client = buildClient(timeoutInMillis, source);
        response = client.execute(request);

        InputStream contentStream = null;
        ByteArrayOutputStream baos = null;
        try {
            contentStream = response.getEntity().getContent();
            baos = new ByteArrayOutputStream();
            AtomicInteger counter = new AtomicInteger();
            byte[] buffer = new byte[1024];
            int offset = 0;
            long startTime = System.currentTimeMillis();
            while ((offset = contentStream.read(buffer)) != -1) {
                counter.addAndGet(offset);
                if (counter.get() > allowedContentSizeInBytes) {
                    throw new ExternalContentTooLargeException(
                            "Content from url " + url + " is larger then " + this.allowedContentSizeInBytes);
                }
                long now = System.currentTimeMillis();
                if (startTime + timeoutInMillis < now) {
                    throw new IOException("Too much time spent reading url: " + url);
                }
                baos.write(buffer, 0, offset);
            }
            Calendar calendar = new CalendarBuilder().build(new ByteArrayInputStream(baos.toByteArray()));
            this.postProcess(calendar);

            Set<NoteItem> externalItems = converter.asItems(calendar);

            validate(externalItems);

            return externalItems;
        } finally {
            close(contentStream);
            close(baos);
        }
    } catch (IOException | URISyntaxException | ParserException e) {
        throw new ExternalContentInvalidException(e);
    } finally {
        close(response);
        close(client);
    }
}
 
Example #23
Source File: IcsFileImporter.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Reads calendar events from file
 * @return a list of events if file was parsed successfully or null otherwise
 */
private static List<CalendarEvent> readEvents(File f) {
  try {
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
    CalendarBuilder builder = new CalendarBuilder();
    List<CalendarEvent> gpEvents = Lists.newArrayList();
    Calendar c = builder.build(new UnfoldingReader(new FileReader(f)));
    for (Component comp : (List<Component>)c.getComponents()) {
      if (comp instanceof VEvent) {
        VEvent event = (VEvent) comp;
        if (event.getStartDate() == null) {
          GPLogger.log("No start date found, ignoring. Event="+event);
          continue;
        }
        Date eventStartDate = event.getStartDate().getDate();
        if (event.getEndDate() == null) {
          GPLogger.log("No end date found, using start date instead. Event="+event);
        }
        Date eventEndDate = event.getEndDate() == null ? eventStartDate : event.getEndDate().getDate();
        TimeDuration oneDay = GPTimeUnitStack.createLength(GPTimeUnitStack.DAY, 1);
        if (eventEndDate != null) {
          java.util.Date startDate = GPTimeUnitStack.DAY.adjustLeft(eventStartDate);
          java.util.Date endDate = GPTimeUnitStack.DAY.adjustLeft(eventEndDate);
          RRule recurrenceRule = (RRule) event.getProperty(Property.RRULE);
          boolean recursYearly = false;
          if (recurrenceRule != null) {
            recursYearly = Recur.YEARLY.equals(recurrenceRule.getRecur().getFrequency()) && 1 == recurrenceRule.getRecur().getInterval();
          }
          while (startDate.compareTo(endDate) <= 0) {
            Summary summary = event.getSummary();
            gpEvents.add(CalendarEvent.newEvent(
                startDate, recursYearly, CalendarEvent.Type.HOLIDAY,
                summary == null ? "" : summary.getValue(),
                null));
            startDate = GPCalendarCalc.PLAIN.shiftDate(startDate, oneDay);
          }
        }
      }
    }
    return gpEvents;
  } catch (IOException | ParserException e) {
    GPLogger.log(e);
    return null;
  }
}
 
Example #24
Source File: CalendarUtils.java    From cosmo with Apache License 2.0 3 votes vote down vote up
/**
    * Parse icalendar data from Reader into Calendar object.
    * 
    * @param reader
    *            icalendar data reader
    * @return Calendar object
    * @throws ParserException
    *             - if something is wrong this exception is thrown.
    * @throws IOException
    *             - if something is wrong this exception is thrown.
    */
   public static Calendar parseCalendar(Reader reader) throws ParserException, IOException {
if (reader == null) {
    return null;
}
CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
clearTZRegistry(builder);
return conformToRfc5545(builder.build(reader));
   }
 
Example #25
Source File: CalendarUtils.java    From cosmo with Apache License 2.0 3 votes vote down vote up
/**
    * Parse icalendar string into Calendar object.
    * 
    * @param calendar
    *            icalendar string
    * @return Calendar object
    * @throws ParserException
    *             - if something is wrong this exception is thrown.
    * @throws IOException
    *             - if something is wrong this exception is thrown.
    */
   public static Calendar parseCalendar(String calendar) throws ParserException, IOException {
if (calendar == null) {
    return null;
}
CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
clearTZRegistry(builder);

StringReader sr = new StringReader(calendar);
return conformToRfc5545(builder.build(sr));
   }
 
Example #26
Source File: TestHelper.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
 * Loads ics.
 * @param name The name.
 * @return The calendar.
 * @throws IOException - if something is wrong this exception is thrown.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
public Calendar loadIcs(String name) throws IOException, ParserException{
    InputStream in = getInputStream(name);
    return calendarBuilder.build(in);
}
 
Example #27
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
 * Parses.
 * {@inheritDoc}
 * @param in The reader.
 * @param handler The content handler.
 * @throws IOException - if something is wrong this exception is thrown.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
public void parse(Reader in,  ContentHandler handler) throws IOException, ParserException {
    parse(new InputSource(in), handler);
}
 
Example #28
Source File: HCalendarParser.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
 * Parses.
 * {@inheritDoc}
 * @param in The input stream.
 * @param handler The content handler.
 * @throws IOException - if something is wrong this exception is thrown.
 * @throws ParserException - if something is wrong this exception is thrown.
 */
public void parse(InputStream in, ContentHandler handler) throws IOException, ParserException {
     parse(new InputSource(in), handler);
}
 
Example #29
Source File: CalendarUtils.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
    * Parse icalendar data from InputStream
    * 
    * @param is
    *            icalendar data inputstream
    * @return Calendar object
    * @throws ParserException
    *             - if something is wrong this exception is thrown.
    * @throws IOException
    *             - if something is wrong this exception is thrown.
    */
   public static Calendar parseCalendar(InputStream is) throws ParserException, IOException {
CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
clearTZRegistry(builder);
return conformToRfc5545(builder.build(is));
   }
 
Example #30
Source File: CalendarUtils.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
    * Parse icalendar data from byte[] into Calendar object.
    * 
    * @param content
    *            icalendar data
    * @return Calendar object
    * @throws ParserException
    *             - if something is wrong this exception is thrown.
    * @throws IOException
    *             - if something is wrong this exception is thrown.
    */
   public static Calendar parseCalendar(byte[] content) throws ParserException, IOException {
CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
clearTZRegistry(builder);
return conformToRfc5545(builder.build(new ByteArrayInputStream(content)));
   }