当前位置: 首页>>代码示例>>Java>>正文


Java CalendarOutputter类代码示例

本文整理汇总了Java中net.fortuna.ical4j.data.CalendarOutputter的典型用法代码示例。如果您正苦于以下问题:Java CalendarOutputter类的具体用法?Java CalendarOutputter怎么用?Java CalendarOutputter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CalendarOutputter类属于net.fortuna.ical4j.data包,在下文中一共展示了CalendarOutputter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: export

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
public void export(Calendar calendar) throws IOException, ValidationException, ParseException {
	String path = AppSettings.get().get("file.upload.dir");
	if (!path.endsWith("/")) {
		path += "/";
       }	
	String name = calendar.getName();
	if (!name.endsWith(".ics")) {
		name += ".ics";
       }
	FileOutputStream fout = new FileOutputStream(path + name );
	Preconditions.checkNotNull(calendar, "calendar can't be null");
	Preconditions.checkNotNull(calendar.getEventsCrm(), "can't export empty calendar");

	net.fortuna.ical4j.model.Calendar cal = newCalendar();
	cal.getProperties().add(new XProperty(X_WR_CALNAME, calendar.getName()));

	for (ICalendarEvent item : calendar.getEventsCrm()) {
		VEvent event = createVEvent(item);
		cal.getComponents().add(event);
	}
	
	CalendarOutputter outputter = new CalendarOutputter();
	outputter.output(cal, fout);
}
 
开发者ID:axelor,项目名称:axelor-business-suite,代码行数:25,代码来源:CalendarService.java

示例2: outputCalendar

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
/**
 * Convert Calendar object to String
 * @param calendar
 * @return string representation of calendar
 * @throws ValidationException - if something is wrong this exception is thrown.
 * @throws IOException - if something is wrong this exception is thrown.
 */
public static String outputCalendar(Calendar calendar) 
    throws ValidationException, IOException {
    if (calendar == null) {
        return null;
    }
    CalendarOutputter outputter = new CalendarOutputter();
    StringWriter sw = new StringWriter();
    outputter.output(calendar, sw);
    return sw.toString();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:18,代码来源:CalendarUtils.java

示例3: export

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
/**
 * Export the calendar to the given output writer.
 *
 * @param calendar
 *            the source {@link ICalendar}
 * @param writer
 *            the output writer
 * @throws IOException
 * @throws ValidationException
 * @throws ParseException 
 */
public void export(ICalendar calendar, Writer writer) throws IOException, ValidationException, ParseException {
	Preconditions.checkNotNull(calendar, "calendar can't be null");
	Preconditions.checkNotNull(writer, "writer can't be null");
	Preconditions.checkNotNull(getICalendarEvents(calendar), "can't export empty calendar");

	Calendar cal = newCalendar();
	cal.getProperties().add(new XProperty(X_WR_CALNAME, calendar.getName()));

	for (ICalendarEvent item : getICalendarEvents(calendar)) {
		VEvent event = createVEvent(item);
		cal.getComponents().add(event);
	}

	CalendarOutputter outputter = new CalendarOutputter();
	outputter.output(cal, writer);
}
 
开发者ID:axelor,项目名称:axelor-business-suite,代码行数:28,代码来源:ICalendarService.java

示例4: writeDataToFile

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
/**
 * Write iCal to File
 *
 * @param _filerPath
 *            - path to '*.ics' file
 * @throws Exception
 *             - in case of error during writing to the file
 */
public void writeDataToFile(String _filerPath) throws Exception {
	String filerPath = _filerPath.endsWith(".ics") ? _filerPath
			: String.format("%s.ics", _filerPath);

	try (FileOutputStream fout = new FileOutputStream(filerPath)) {
		CalendarOutputter outputter = new CalendarOutputter();
		outputter.output(icsCalendar, fout);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:18,代码来源:IcalHandler.java

示例5: printICalSchedule

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
protected void printICalSchedule(String calendarName, List<String> calRefs, OutputStream os)
//	protected void printICalSchedule(String calRef, OutputStream os) 
		throws PermissionException
	{
		// generate iCal text file 
		net.fortuna.ical4j.model.Calendar ical = new net.fortuna.ical4j.model.Calendar();
		ical.getProperties().add(new ProdId("-//SakaiProject//iCal4j 1.0//EN"));
		ical.getProperties().add(Version.VERSION_2_0);
		ical.getProperties().add(CalScale.GREGORIAN);
		ical.getProperties().add(new XProperty("X-WR-CALNAME", calendarName));
		ical.getProperties().add(new XProperty("X-WR-CALDESC", calendarName));
		
		TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); 
		TzId tzId = new TzId( m_timeService.getLocalTimeZone().getID() ); 
		ical.getComponents().add(registry.getTimeZone(tzId.getValue()).getVTimeZone());
		
		CalendarOutputter icalOut = new CalendarOutputter();
		int numEvents = generateICal(ical, calRefs);
			
		try 
		{
			if (numEvents > 0) {
				icalOut.output( ical, os );
			}
		}
		catch (Exception e)
		{
           log.warn(".printICalSchedule(): ", e);
		}
	}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:31,代码来源:BaseCalendarService.java

示例6: writeCalendarFile

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
private boolean writeCalendarFile(final Calendar calendar, final String calType, final String calId) {
    final File fCalendarFile = getCalendarFile(calType, calId);
    OutputStream os = null;
    try {
        os = new BufferedOutputStream(new FileOutputStream(fCalendarFile, false));
        final CalendarOutputter calOut = new CalendarOutputter(false);
        calOut.output(calendar, os);
    } catch (final Exception e) {
        return false;
    } finally {
        FileUtils.closeSafely(os);
    }
    return true;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:15,代码来源:CalendarDaoICalFileImpl.java

示例7: userCalDavCalendar

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
@RequestMapping(value = "/api/calendar/{token}/calendar.ics", method = RequestMethod.GET, produces = "text/calendar")
public void userCalDavCalendar(@PathVariable("token") String userToken, HttpServletResponse response)
    throws IOException, URISyntaxException, ParseException {
    Calendar calendar = calendarService.getCalDavCalendar(userToken);
    response.setContentType("text/calendar");
    CalendarOutputter output = new CalendarOutputter(false); // <- no validation on the output
    output.output(calendar, response.getOutputStream());
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:9,代码来源:CalendarController.java

示例8: getOutputer

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
public CalendarOutputter getOutputer() {
    return outputer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ICalDataFormat.java

示例9: setOutputer

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
public void setOutputer(CalendarOutputter outputer) {
    this.outputer = outputer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ICalDataFormat.java

示例10: main

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	calendar = new Calendar();
	calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
	calendar.getProperties().add(Version.VERSION_2_0);
	calendar.getProperties().add(CalScale.GREGORIAN);
	java.util.Calendar javaCalendar = java.util.Calendar.getInstance();
	javaCalendar.set(java.util.Calendar.MONTH, java.util.Calendar.DECEMBER);
	javaCalendar.set(java.util.Calendar.DAY_OF_MONTH, 25);

	// initialise as an all-day event..
	VEvent christmas = new VEvent(new Date(javaCalendar.getTime()), "Christmas Day");

	// Generate a UID for the event..
	UidGenerator ug = new UidGenerator("1");
	christmas.getProperties().add(ug.generateUid());

	calendar.getComponents().add(christmas);


	JSONArray jsonArray = readJsonFromUrl(VERSION_TRACK_URL);
	String name;
	String url;
	String venue;
	String mapLocation;
	String version;
	String forceTrack;

	for (int i = 0; i < jsonArray.length(); i++) {
		try {
			name = jsonArray.getJSONObject(i).getJSONArray("c").getJSONObject(0)
					.getString("v");
			url = jsonArray.getJSONObject(i).getJSONArray("c").getJSONObject(1)
					.getString("f");
			venue = jsonArray.getJSONObject(i).getJSONArray("c").getJSONObject(2)
					.getString("v");
			version = jsonArray.getJSONObject(i).getJSONArray("c").getJSONObject(8)
					.getString("v");
			mapLocation = jsonArray.getJSONObject(i).getJSONArray("c").getJSONObject(5)
					.getString("v");

			fetchData(PART_URL+url, venue, name, (i+23)*100);





		} catch (JSONException e) {
			e.printStackTrace();
		}

	}

	FileOutputStream fout = new FileOutputStream("mycalendar.ics");

	CalendarOutputter outputter = new CalendarOutputter();
	outputter.output(calendar, fout);

}
 
开发者ID:OpnTec,项目名称:ots15-companion,代码行数:59,代码来源:Main.java

示例11: simpleInvitionIcalLink

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
public void simpleInvitionIcalLink() {
	// Create a TimeZone
	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
	TimeZone timezone = registry.getTimeZone("America/Mexico_City");
	VTimeZone tz = timezone.getVTimeZone();

	// Start Date is on: April 1, 2008, 9:00 am
	java.util.Calendar startDate = new GregorianCalendar();
	startDate.setTimeZone(timezone);
	startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
	startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
	startDate.set(java.util.Calendar.YEAR, 2008);
	startDate.set(java.util.Calendar.HOUR_OF_DAY, 9);
	startDate.set(java.util.Calendar.MINUTE, 0);
	startDate.set(java.util.Calendar.SECOND, 0);

	// End Date is on: April 1, 2008, 13:00
	java.util.Calendar endDate = new GregorianCalendar();
	endDate.setTimeZone(timezone);
	endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
	endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
	endDate.set(java.util.Calendar.YEAR, 2008);
	endDate.set(java.util.Calendar.HOUR_OF_DAY, 13);
	endDate.set(java.util.Calendar.MINUTE, 0);
	endDate.set(java.util.Calendar.SECOND, 0);

	// Create the event
	String eventName = "Progress Meeting";
	DateTime start = new DateTime(startDate.getTime());
	DateTime end = new DateTime(endDate.getTime());
	VEvent meeting = new VEvent(start, end, eventName);

	// add timezone info..
	meeting.getProperties().add(tz.getTimeZoneId());

	// generate unique identifier..
	Uid uid = new Uid(UUID.randomUUID().toString());
	meeting.getProperties().add(uid);

	// add attendees..
	Attendee dev1 = new Attendee(URI.create("mailto:[email protected]"));
	dev1.getParameters().add(Role.REQ_PARTICIPANT);
	dev1.getParameters().add(new Cn("Developer 1"));
	meeting.getProperties().add(dev1);

	Attendee dev2 = new Attendee(URI.create("mailto:[email protected]"));
	dev2.getParameters().add(Role.OPT_PARTICIPANT);
	dev2.getParameters().add(new Cn("Developer 2"));
	meeting.getProperties().add(dev2);

	// Create a calendar
	net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
	icsCalendar.getProperties().add(
			new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
	icsCalendar.getProperties().add(CalScale.GREGORIAN);
	icsCalendar.getProperties().add(Version.VERSION_2_0);

	// Add the event and print
	icsCalendar.getComponents().add(meeting);

	Organizer orger = new Organizer(URI.create("[email protected]"));
	orger.getParameters().add(new Cn("Sebastian Wagner"));
	meeting.getProperties().add(orger);

	icsCalendar.getProperties().add(Method.REQUEST);

	log.debug(icsCalendar.toString());

	ByteArrayOutputStream bout = new ByteArrayOutputStream();
	CalendarOutputter outputter = new CalendarOutputter();
	try {
		outputter.output(icsCalendar, bout);
		iCalMimeBody = bout.toByteArray();

		sendIcalMessage();
	} catch (Exception e) {
		log.error("Error", e);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:80,代码来源:TestSendIcalMessage.java

示例12: doGet

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException
{
  if (WebConfiguration.isUpAndRunning() == false) {
    log.error("System isn't up and running, CalendarFeed call denied. The system is may-be in start-up phase or in maintenance mode.");
    resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
    return;
  }
  PFUserDO user = null;
  String logMessage = null;
  try {
    MDC.put("ip", req.getRemoteAddr());
    MDC.put("session", req.getSession().getId());
    if (StringUtils.isBlank(req.getParameter("user")) || StringUtils.isBlank(req.getParameter("q"))) {
      resp.sendError(HttpStatus.SC_BAD_REQUEST);
      log.error("Bad request, parameters user and q not given. Query string is: " + req.getQueryString());
      return;
    }
    final String encryptedParams = req.getParameter("q");
    final Integer userId = NumberHelper.parseInteger(req.getParameter("user"));
    if (userId == null) {
      log.error("Bad request, parameter user is not an integer: " + req.getQueryString());
      return;
    }
    final Registry registry = Registry.instance();
    user = registry.getUserGroupCache().getUser(userId);
    if (user == null) {
      log.error("Bad request, user not found: " + req.getQueryString());
      return;
    }
    PFUserContext.setUser(user);
    MDC.put("user", user.getUsername());
    final String decryptedParams = registry.getDao(UserDao.class).decrypt(userId, encryptedParams);
    if (decryptedParams == null) {
      log.error("Bad request, can't decrypt parameter q (may-be the user's authentication token was changed): " + req.getQueryString());
      return;
    }
    final Map<String, String> params = StringHelper.getKeyValues(decryptedParams, "&");
    final Calendar calendar = createCal(params, userId, params.get("token"), params.get(PARAM_NAME_TIMESHEET_USER));
    final StringBuffer buf = new StringBuffer();
    boolean first = true;
    for (final Map.Entry<String, String> entry : params.entrySet()) {
      if ("token".equals(entry.getKey()) == true) {
        continue;
      }
      first = StringHelper.append(buf, first, entry.getKey(), ", ");
      buf.append("=").append(entry.getValue());
    }
    logMessage = buf.toString();
    log.info("Getting calendar entries for: " + logMessage);

    if (calendar == null) {
      resp.sendError(HttpStatus.SC_BAD_REQUEST);
      log.error("Bad request, can't find calendar.");
      return;
    }

    resp.setContentType("text/calendar");
    final CalendarOutputter output = new CalendarOutputter(false);
    try {
      output.output(calendar, resp.getOutputStream());
    } catch (final ValidationException ex) {
      ex.printStackTrace();
    }
  } finally {
    log.info("Finished request: " + logMessage);
    PFUserContext.setUser(null);
    MDC.remove("ip");
    MDC.remove("session");
    if (user != null) {
      MDC.remove("user");
    }
  }
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:75,代码来源:CalendarFeed.java

示例13: okPressed

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
@Override
protected void okPressed(){
	von.setTimeInMillis(dpVon.getDate().getTime());
	bis.setTimeInMillis(dpBis.getDate().getTime());
	Query<Termin> qbe = new Query<Termin>(Termin.class);
	qbe.add(Termin.FLD_TAG, Query.GREATER_OR_EQUAL, von.toString(TimeTool.DATE_COMPACT));
	qbe.add(Termin.FLD_TAG, Query.LESS_OR_EQUAL, bis.toString(TimeTool.DATE_COMPACT));
	qbe.add(Termin.FLD_BEREICH, Query.EQUALS, m);
	List<Termin> termine = qbe.execute();
	String fname = lFile.getText();
	if (fname.toLowerCase().endsWith(".csv")) { //$NON-NLS-1$
		new CSVExporter().doExport(fname, termine);
	} else {
		TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
		TimeZone timezone = registry.getTimeZone("Europe/Zurich"); //$NON-NLS-1$
		VTimeZone tz = timezone.getVTimeZone();
		Calendar calendar = new Calendar();
		calendar.getProperties().add(new ProdId("-//ch.elexis//Elexis v" + CoreHub.Version)); //$NON-NLS-1$
		calendar.getProperties().add(Version.VERSION_2_0);
		calendar.getProperties().add(CalScale.GREGORIAN);
		for (Termin t : termine) {
			if ((t.getStartMinute() == 0) && (t.getType().equals(Termin.typReserviert()))) {
				continue;
			}
			if ((t.getStartMinute() + t.getDurationInMinutes() == (23 * 60) + 59)
				&& (t.getType().equals(Termin.typReserviert()))) {
				continue;
			}
			TimeTool tt = new TimeTool(t.getStartTime());
			DateTime start = new DateTime(tt.getTime());
			tt.addMinutes(t.getDurationInMinutes());
			DateTime end = new DateTime(tt.getTime());
			VEvent vTermin = new VEvent(start, end, t.getPersonalia());
			vTermin.getProperties().add(tz.getTimeZoneId());
			Uid uid = new Uid(t.getId());
			vTermin.getProperties().add(uid);
			Description desc = new Description(t.getGrund());
			vTermin.getProperties().add(desc);
			calendar.getComponents().add(vTermin);
		}
		try {
			FileOutputStream fout = new FileOutputStream(lFile.getText());
			CalendarOutputter outputter = new CalendarOutputter();
			outputter.output(calendar, fout);
			
		} catch (Exception ex) {
			ExHandler.handle(ex);
			SWTHelper.alert(
				Messages.ICalTransfer_iOError,
				MessageFormat.format(Messages.ICalTransfer_couldNotWriteFile,
					lFile.getText()));
		}
	}
	super.okPressed();
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:56,代码来源:ICalTransfer.java

示例14: getIcalAsByteArray

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
/**
 * Get IcalBody as ByteArray
 *
 * @return - calendar in ICS format as byte[]
 * @throws Exception
 *             - in case of error during writing to byte array
 */
public byte[] getIcalAsByteArray() throws Exception {
	ByteArrayOutputStream bout = new ByteArrayOutputStream();
	CalendarOutputter outputter = new CalendarOutputter();
	outputter.output(icsCalendar, bout);
	return bout.toByteArray();
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:14,代码来源:IcalHandler.java

示例15: output

import net.fortuna.ical4j.data.CalendarOutputter; //导入依赖的package包/类
/**
 * Writes an iCalendar string representing the calendar items
 * contained within the given calendar collection to the given
 * output stream.
 *
 * Since the calendar content stored with each calendar items
 * is parsed and validated when the item is created, these
 * errors should not reoccur when the calendar is being
 * outputted.
 *
 * @param collection the <code>CollectionItem</code> to format
 *
 * @throws IllegalArgumentException if the collection is not
 * stamped as a calendar collection
 * @throws IOException
 */
public static void output(Calendar calendar,
                          OutputStream out)
    throws IOException {
   
    CalendarOutputter outputter = new CalendarOutputter();
    outputter.setValidating(false);
    try {
        outputter.output(calendar, out);
    } catch (ValidationException e) {
        throw new IllegalStateException("unable to validate collection calendar", e);
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:29,代码来源:ICalendarOutputter.java


注:本文中的net.fortuna.ical4j.data.CalendarOutputter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。