Package net.fortuna.ical4j.data

Examples of net.fortuna.ical4j.data.CalendarBuilder


    public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
        Preconditions.checkNotNull(baseURI);

        setBaseURI(baseURI);
        try {
            parseCalendar(new CalendarBuilder().build(in));
        } catch (ParserException e) {
            throw new RDFParseException(e);
        }
    }
View Full Code Here


    public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
        Preconditions.checkNotNull(baseURI);

        setBaseURI(baseURI);
        try {
            parseCalendar(new CalendarBuilder().build(reader));
        } catch (ParserException e) {
            throw new RDFParseException(e);
        }
    }
View Full Code Here

      }
      buf.append(ch);
    }
    final String displayUrl = buf.toString();
    log.info("Getting subscribed calendar #" + teamCalDo.getId() + " from: " + displayUrl);
    final CalendarBuilder builder = new CalendarBuilder();
    byte[] bytes = null;
    try {

      // Create a method instance.
      final GetMethod method = new GetMethod(url);

      final int statusCode = client.executeMethod(method);

      if (statusCode != HttpStatus.SC_OK) {
        log.error("Unable to gather subscription calendar #"
            + teamCalDo.getId()
            + " information, using database from url '"
            + displayUrl
            + "'. Received statusCode: "
            + statusCode);
        return;
      }

      final MessageDigest md = MessageDigest.getInstance("MD5");

      // Read the response body.
      final InputStream stream = method.getResponseBodyAsStream();
      bytes = IOUtils.toByteArray(stream);

      final String md5 = calcHexHash(md.digest(bytes));
      if (StringUtils.equals(md5, teamCalDo.getExternalSubscriptionHash()) == false) {
        teamCalDo.setExternalSubscriptionHash(md5);
        teamCalDo.setExternalSubscriptionCalendarBinary(bytes);
        // internalUpdate is valid at this point, because we are calling this method in an async thread
        teamCalDao.internalUpdate(teamCalDo);
      }
    } catch (final Exception e) {
      bytes = teamCalDo.getExternalSubscriptionCalendarBinary();
      log.error("Unable to gather subscription calendar #"
          + teamCalDo.getId()
          + " information, using database from url '"
          + displayUrl
          + "': "
          + e.getMessage(), e);
    }
    if (bytes == null) {
      log.error("Unable to use database subscription calendar #" + teamCalDo.getId() + " information, quit from url '" + displayUrl + "'.");
      return;
    }
    if (currentInitializedHash != null && StringUtils.equals(currentInitializedHash, teamCalDo.getExternalSubscriptionHash()) == true) {
      // nothing to do here if the hashes are equal
      log.info("No modification of subscribed calendar #" + teamCalDo.getId() + " found from: " + displayUrl + " (OK, nothing to be done).");
      return;
    }
    try {
      final Date timeInPast = new Date(System.currentTimeMillis() - TIME_IN_THE_PAST);
      final Calendar calendar = builder.build(new ByteArrayInputStream(bytes));
      @SuppressWarnings("unchecked")
      final List<Component> list = calendar.getComponents(Component.VEVENT);
      final List<VEvent> vEvents = new ArrayList<VEvent>();
      for (final Component c : list) {
        final VEvent event = (VEvent) c;
View Full Code Here

    if (fileUpload != null) {
      try {
        final InputStream is = fileUpload.getInputStream();
        actionLog.reset();
        final String clientFilename = fileUpload.getClientFileName();
        final CalendarBuilder builder = new CalendarBuilder();
        final Calendar calendar = builder.build(is);
        final ImportStorage<TeamEventDO> storage = teamCalImportDao.importEvents(calendar, clientFilename, actionLog);
        setStorage(storage);
      } catch (final Exception ex) {
        log.error(ex.getMessage(), ex);
        error("An error occurred (see log files for details): " + ex.getMessage());
View Full Code Here

  @Override
  protected void onStringImport(final AjaxRequestTarget target, final String fileName, final String content)
  {

    try {
      final CalendarBuilder builder = new CalendarBuilder();
      final Calendar calendar = builder.build(new StringReader(content));
      onIcsImport(target, calendar);
    } catch (final Exception ex) {
      // TODO ju: handle exception
      log.fatal("unable to import dropped calendar", ex);
    }
View Full Code Here

    }

    public static final Calendar asIcal4jCalendar(final String rawResponse) throws InfusionsoftResponseParsingException {
        final String responseString = (String)rawResponse;
        final StringReader reader = new StringReader(responseString);
        final CalendarBuilder builder = new CalendarBuilder();
        try {
            return builder.build(reader);
        } catch (IOException e) {
            // unreachable
            throw new InfusionsoftResponseParsingException("Unable to fetch calendar. ", e);
        } catch (ParserException e) {
            throw new InfusionsoftResponseParsingException("Unable to parse calendar. ", e);
View Full Code Here

TOP

Related Classes of net.fortuna.ical4j.data.CalendarBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.