本文整理汇总了Java中net.fortuna.ical4j.model.ValidationException类的典型用法代码示例。如果您正苦于以下问题:Java ValidationException类的具体用法?Java ValidationException怎么用?Java ValidationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationException类属于net.fortuna.ical4j.model包,在下文中一共展示了ValidationException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: export
import net.fortuna.ical4j.model.ValidationException; //导入依赖的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);
}
示例2: export
import net.fortuna.ical4j.model.ValidationException; //导入依赖的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);
}
示例3: addEmailGuest
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
@Transactional
public void addEmailGuest(EmailAddress email, Event event) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, MessagingException, IOException, ICalendarException, ValidationException, ParseException{
if(event.getAttendees() != null && email != null){
boolean exist = false;
for (ICalendarUser attendee : event.getAttendees()) {
if(email.getAddress().equals(attendee.getEmail())){
exist = true;
break;
}
}
if(!exist){
ICalendarUser calUser = new ICalendarUser();
calUser.setEmail(email.getAddress());
calUser.setName(email.getName());
if(email.getPartner() != null && email.getPartner().getUser() != null){
calUser.setUser(email.getPartner().getUser());
}
event.addAttendee(calUser);
eventRepo.save(event);
}
}
}
示例4: getICalendar
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
/** Returns a calendar derived from a Work Effort calendar publish point.
* @param workEffortId ID of a work effort with <code>workEffortTypeId</code> equal to
* <code>PUBLISH_PROPS</code>.
* @param context The conversion context
* @return An iCalendar as a <code>String</code>, or <code>null</code>
* if <code>workEffortId</code> is invalid.
* @throws GenericEntityException
*/
public static ResponseProperties getICalendar(String workEffortId, Map<String, Object> context) throws GenericEntityException {
Delegator delegator = (Delegator) context.get("delegator");
GenericValue publishProperties = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffortId).queryOne();
if (!isCalendarPublished(publishProperties)) {
Debug.logInfo("WorkEffort calendar is not published: " + workEffortId, module);
return ICalWorker.createNotFoundResponse(null);
}
if (!"WES_PUBLIC".equals(publishProperties.get("scopeEnumId"))) {
if (context.get("userLogin") == null) {
return ICalWorker.createNotAuthorizedResponse(null);
}
if (!hasPermission(workEffortId, "VIEW", context)) {
return ICalWorker.createForbiddenResponse(null);
}
}
Calendar calendar = makeCalendar(publishProperties, context);
ComponentList components = calendar.getComponents();
List<GenericValue> workEfforts = getRelatedWorkEfforts(publishProperties, context);
if (workEfforts != null) {
for (GenericValue workEffort : workEfforts) {
ResponseProperties responseProps = toCalendarComponent(components, workEffort, context);
if (responseProps != null) {
return responseProps;
}
}
}
if (Debug.verboseOn()) {
try {
calendar.validate(true);
Debug.logVerbose("iCalendar passes validation", module);
} catch (ValidationException e) {
Debug.logVerbose("iCalendar fails validation: " + e, module);
}
}
return ICalWorker.createOkResponse(calendar.toString());
}
示例5: getICalendar
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
/** Returns a calendar derived from a Work Effort calendar publish point.
* @param workEffortId ID of a work effort with <code>workEffortTypeId</code> equal to
* <code>PUBLISH_PROPS</code>.
* @param context The conversion context
* @return An iCalendar as a <code>String</code>, or <code>null</code>
* if <code>workEffortId</code> is invalid.
* @throws GenericEntityException
*/
public static ResponseProperties getICalendar(String workEffortId, Map<String, Object> context) throws GenericEntityException {
Delegator delegator = (Delegator) context.get("delegator");
GenericValue publishProperties = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId), false);
if (!isCalendarPublished(publishProperties)) {
Debug.logInfo("WorkEffort calendar is not published: " + workEffortId, module);
return ICalWorker.createNotFoundResponse(null);
}
if (!"WES_PUBLIC".equals(publishProperties.get("scopeEnumId"))) {
if (context.get("userLogin") == null) {
return ICalWorker.createNotAuthorizedResponse(null);
}
if (!hasPermission(workEffortId, "VIEW", context)) {
return ICalWorker.createForbiddenResponse(null);
}
}
Calendar calendar = makeCalendar(publishProperties, context);
ComponentList components = calendar.getComponents();
List<GenericValue> workEfforts = getRelatedWorkEfforts(publishProperties, context);
if (workEfforts != null) {
for (GenericValue workEffort : workEfforts) {
ResponseProperties responseProps = toCalendarComponent(components, workEffort, context);
if (responseProps != null) {
return responseProps;
}
}
}
if (Debug.verboseOn()) {
try {
calendar.validate(true);
Debug.logVerbose("iCalendar passes validation", module);
} catch (ValidationException e) {
Debug.logVerbose("iCalendar fails validation: " + e, module);
}
}
return ICalWorker.createOkResponse(calendar.toString());
}
示例6: addEmailGuest
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void addEmailGuest(ActionRequest request, ActionResponse response) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, MessagingException, IOException, ICalendarException, ValidationException, ParseException{
Event event = request.getContext().asType(Event.class);
if(request.getContext().containsKey("guestEmail")){
EmailAddress emailAddress = Beans.get(EmailAddressRepository.class).find(new Long(((Map<String, Object>) request.getContext().get("guestEmail")).get("id").toString()));
if(emailAddress != null){
event = eventRepo.find(event.getId());
eventService.addEmailGuest(emailAddress, event);
}
}
response.setReload(true);
}
示例7: exportCalendar
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
public void exportCalendar(ActionRequest request, ActionResponse response) throws IOException, ParserException, ValidationException, ObjectStoreException, ObjectNotFoundException, ParseException {
Calendar cal = request.getContext().asType(Calendar.class);
calendarService.export(cal);
}
示例8: sendMail
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
@Transactional
public void sendMail(Event event, String email) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, ValidationException, ParseException, ICalendarException{
EmailAddress emailAddress = Beans.get(EmailAddressRepository.class).all().filter("self.address = ?1", email).fetchOne();
User user = Beans.get(UserRepository.class).all().filter("self.partner.emailAddress.address = ?1", email).fetchOne();
CrmConfig crmConfig = Beans.get(CrmConfigService.class).getCrmConfig(user.getActiveCompany());
if(crmConfig.getSendMail() == true) {
if(emailAddress == null){
emailAddress = new EmailAddress(email);
}
Template guestAddedTemplate = crmConfig.getMeetingGuestAddedTemplate();
Message message = new Message();
if(guestAddedTemplate == null){
if(message.getFromEmailAddress() == null){
message.setFromEmailAddress(user.getPartner().getEmailAddress());
}
message.addToEmailAddressSetItem(emailAddress);
message.setSubject(event.getSubject());
message.setMailAccount(Beans.get(MailAccountService.class).getDefaultMailAccount());
}
else{
message = Beans.get(TemplateMessageService.class).generateMessage(event, guestAddedTemplate);
if(message.getFromEmailAddress() == null){
message.setFromEmailAddress(user.getPartner().getEmailAddress());
}
message.addToEmailAddressSetItem(emailAddress);
}
if(event.getUid() != null){
CalendarService calendarService = Beans.get(CalendarService.class);
Calendar cal = calendarService.getCalendar(event.getUid(), event.getCalendarCrm());
cal.getProperties().add(Method.REQUEST);
File file = calendarService.export(cal);
Path filePath = file.toPath();
MetaFile metaFile = new MetaFile();
metaFile.setFileName( file.getName() );
metaFile.setFileType( Files.probeContentType( filePath ) );
metaFile.setFileSize( Files.size( filePath ) );
metaFile.setFilePath( file.getName() );
Set<MetaFile> fileSet = new HashSet<MetaFile>();
fileSet.add(metaFile);
Beans.get(MessageRepository.class).save(message);
Beans.get(MessageService.class).attachMetaFiles(message, fileSet);
}
message = Beans.get(MessageService.class).sendByEmail(message);
}
}
示例9: doGet
import net.fortuna.ical4j.model.ValidationException; //导入依赖的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");
}
}
}
示例10: VCardItemElementHandler
import net.fortuna.ical4j.model.ValidationException; //导入依赖的package包/类
public VCardItemElementHandler(final FileInputStream fis){
final DataInputStream in = new DataInputStream(fis);
final BufferedReader br = new BufferedReader(new InputStreamReader(in));
itemList = new ArrayList<Property>();
//Read File Line By Line
try {
String strLine;
while ((strLine = br.readLine()) != null) {
// looking for a item entry
if (strLine.startsWith("item") && !strLine.contains("X-AB")) {
// dissect the line by char
final String str[] = StringUtils.splitByCharacterType(strLine);
/*
* ignore "item" + "number" + "." (example: "item2.") cause is not needed.
* at index = 3 is the GroupId
*/
final int n = 3;
// set Property.Id
final Id id = getItemId(str[n]);
final ArrayList<Parameter> param = new ArrayList<Parameter>();
boolean startSignFound = false;
String valueCache = "";
for (int i = n; i < str.length; i++){
// looking for parameters
if (str[i].equals("WORK") || str[i].equals("HOME")){
param.add(getParameter(str[i]));
}
/*
* looking for start sign.
* usually ":" but sometimes addresses starts with ":;;"
*/
if (str[i].equals(":;;") || str[i].equals(":") || str[i].equals(":;") && !startSignFound){
startSignFound = true;
} else
if (startSignFound) {
// terminate unwanted signs.
if(str[i].equals(";") || str[i].equals(";;") || str[i].equals(".;"))
valueCache = valueCache + ";";
else
valueCache = valueCache + str[i];
}
}
final String finalValue = valueCache;
// set property with group at index = 3
@SuppressWarnings("serial")
final Property property = new Property(new Group(str[n]), id, param) {
@Override
public void validate() throws ValidationException
{
}
@Override
public String getValue()
{
return finalValue;
}
};
itemList.add(property);
}
}
// for (final Property p : itemList){
// System.out.println("propterty val: " + p.getValue() + " ;;; id: " + p.getId() + " ;;; parameter: " + p.getParameters(Parameter.Id.TYPE));
// }
in.close();
} catch (final IOException ex) {
// log.fatal("Exception encountered " + ex, ex);
}
}