Not getting invite acceptation email in ical4j - java

I am using the iCal4j for sending the calendar invite. I am able to send the invite to user. But when user accepting the invite I am not getting the revert mail.
net.fortuna.ical4j.model.Calendar cal = new net.fortuna.ical4j.model.Calendar();
cal.getProperties().add(new ProdId("//Google Inc//Google Calendar 70.9054//EN"));
cal.getProperties().add(Version.VERSION_2_0);
cal.getProperties().add(CalScale.GREGORIAN);
System.setProperty(CompatibilityHints.KEY_OUTLOOK_COMPATIBILITY, "true");
java.util.Calendar c1 = java.util.Calendar.getInstance();
c1.add(java.util.Calendar.HOUR, 1);
c1.add(java.util.Calendar.DATE, 1);
DateTime start = new DateTime(c1.getTime());
c1.add(java.util.Calendar.HOUR, 1);
DateTime end = new DateTime(c1.getTime());
VEvent vEvent = new VEvent();
vEvent.getProperties().add(new DtStart(start));
vEvent.getProperties().add(new DtEnd(end));
vEvent.getProperties().add(Clazz.PUBLIC);
Organizer organizer = new Organizer(URI.create("mailto:mail#gmail.com"));
organizer.getParameters().add(new Cn("mail#gmail.com"));
vEvent.getProperties().add(organizer);
UidGenerator uid = new RandomUidGenerator();
vEvent.getProperties().add(uid.generateUid());
Attendee attendee1 = new Attendee(URI.create("mailto:mail#yahoo.com"));
attendee1.getParameters().add(CuType.INDIVIDUAL);
attendee1.getParameters().add(Role.REQ_PARTICIPANT);
attendee1.getParameters().add(PartStat.NEEDS_ACTION);
attendee1.getParameters().add(Rsvp.TRUE);
attendee1.getParameters().add(new Cn("mail#yahoo.com"));
vEvent.getProperties().add(attendee1);
vEvent.getProperties().add(new Description("some description");
vEvent.getProperties().add(new Location("location"));
vEvent.getProperties().add(Status.VEVENT_CONFIRMED);
vEvent.getProperties().add(new Summary("Invite summery"));
vEvent.getProperties().add(Transp.OPAQUE);
Any suggestion???

When sending calendar invites you need to include directives that tell the client software (e.g. Outlook, etc.) how it should handle the event. This is done via the METHOD property:
http://ical4j.github.io/docs/ical4j/api/3.0.26/net/fortuna/ical4j/model/property/Method.html
Usually you would use either METHOD:PUBLISH for events that don't require a response, or METHOD:REQUEST where you want accept/decline response.
So if you add METHOD:REQUEST property to your invitation you should get a response.

Related

iOS not receiving pending push after turn on Internet from Azure Notification Hub

I'm working on integrating Azure Notification Hub with a Java backend to send notifications of the latest news to Android and iOS devices.
In recent days I've identified the following issue, iOS devices don't receive notifications that were sent when the devices were off the internet. Notifications are lost and are not sent back to devices when the internet is turned on.
To overcome this problem I added the value of the expiration date, as you can see in the example below, but the problem persists.
Date now = new Date();
Date expiry = new Date(now.getTime() + 259200000L);
NotificationHub hub = new NotificationHub("connectionString", "hubPath");
String alert = "{\"aps\":{\"alert\":\""+notification.getBody()+"\",\"body\":\""+notification.getTitle()+"\",\"sound\":\"default\",\"id-news\":\""+notification.getIdNews()+"\"}}";
Notification ios = Notification.createAppleNotification(alert,expiry);
hub.sendNotification(ios);
A second option I added the ServiceBusNotification-Apns-Expiry values and apns-expiration directly in the header but the problem continues.
Date now = new Date();
Date expiry = new Date(now.getTime() + 259200000L);
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
String expiryString = formatter.format(expiry.getTime());
Map<String, String> headers = new HashMap<>();
headers.put("ServiceBusNotification-Format", "apple");
headers.put("apns-push-type", "alert");
headers.put("apns-priority", "10");
headers.put("ServiceBusNotification-Apns-Expiry", expiryString);
headers.put("apns-expiration", "259200000");
NotificationHub hub = new NotificationHub("connectionString", "hubPath");
String alert = "{\"aps\":{\"alert\":\""+notification.getBody()+"\",\"body\":\""+notification.getTitle()+"\",\"sound\":\"default\",\"id-news\":\""+notification.getIdNews()+"\"}}";
Notification ios = Notification.createAppleNotification(alert,headers);
hub.sendNotification(ios);

How to get shared calendar list using caldav4j from davical?

I created my own calendar using netbeans, caldav4j and Davical. However, I can't get shared calendar list.
I can create a calendar or an event. I can see them at Agendav. But when I share calendar to other users at Agendav, I can't get it with my netbeans code.
I want to show which user shared calendar with me.
HttpClient http = createHttpClient();
HostConfiguration hostConfig = createHostConfiguration();
PropFindMethod propfind = new PropFindMethod();
propfind.setPath(caldavCredential.home);
PropProperty propFindTag = PropertyFactory.createProperty(PropertyFactory.PROPFIND);
PropProperty aclTag = PropertyFactory.createProperty(PropertyFactory.ACL);
PropProperty propTag = new PropProperty(CalDAVConstants.NS_DAV,"D","prop");
propTag.addChild(aclTag);
propFindTag.addChild(propTag);
propfind.setPropFindRequest(propFindTag);
propfind.setDepth(0);
executeMethod(hostConfig, propfind);
Set<String> keySet = (propfind.getResponseHashtable()).keySet();
for(String key: keySet){
CalDAVResponse response = (propfind.getResponseHashtable()).get(key);
String href = response.getHref();
Ace[] aces = propfind.getAces(href);
Enumeration enumerations = aces.enumeratePriviliges();
while(enumerations.hasMoreElements()){
Privilege privilege = (Privilege)enumerations.nextElement();
System.out.println("parameter: " + privilege.getParameter());
}
}
I try to get privileges but there is no parameter. I only want which user shared calendars with me. I can make calendar, add event but I can't access shared calendar list.

Events from database show to google calendar

I am developing an app, which works like a booking system. The main-component is a calendar which shows created events, which are stored in PostgreSQL database. My challenge now, is to show all the events from database to the adminĀ“s google calendar. When the admin opens his google calendar, he only has rights to see the events, but not to edit them.
The technologies i am using is Apache/Tomcat, Java, Spring and Hibernate.
Can someone help me, or guide me to some clear solution?
If you are looking for guide, then the documentation can help you a lot.
First thing, you need to understand the concept of Google Calendar API. You can read the basic concept on the overview page for further details. Moreover, if your aim is just more on the events, then you will need to make sure that you have visited this.
Here is a sample snippet all the way from the sample given in the documentation. This sample demonstrate creating an event and setting its metadata:
// Refer to the Java quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/java
// Change the scope to CalendarScopes.CALENDAR and delete any stored
// credentials.
Event event = new Event()
.setSummary("Google I/O 2015")
.setLocation("800 Howard St., San Francisco, CA 94103")
.setDescription("A chance to hear more about Google's developer products.");
DateTime startDateTime = new DateTime("2015-05-28T09:00:00-07:00");
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("America/Los_Angeles");
event.setStart(start);
DateTime endDateTime = new DateTime("2015-05-28T17:00:00-07:00");
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("America/Los_Angeles");
event.setEnd(end);
String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"};
event.setRecurrence(Arrays.asList(recurrence));
EventAttendee[] attendees = new EventAttendee[] {
new EventAttendee().setEmail("lpage#example.com"),
new EventAttendee().setEmail("sbrin#example.com"),
};
event.setAttendees(Arrays.asList(attendees));
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("email").setMinutes(24 * 60),
new EventReminder().setMethod("popup").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);
String calendarId = "primary";
event = service.events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getHtmlLink());

EWS Java get meetings

I am trying to integrate exchange calendar with my custom calendar. Till now i am able to integrate new creation of meeting from my calendar to Exchange.
But the issue i am facing is from Exchange to my calendar. If i create a new meeting in outlook, and and if i search it through below code i am getting results.
<code>
CalendarFolder calendarFolder = CalendarFolder.bind(eService, WellKnownFolderName.Calendar);
CalendarView calendarView = new CalendarView(startOfMonth.toDate(), endOfMonth.toDate());
FindItemsResults<Appointment> aprilMeetings = alendarFolder.findAppointments(calendarView);
</code>
in above list i am getting all meetings between start and end date. My question is how to identify whether its a new meeting or updated meeting or canceled meeting.
I tried these methods,
<code>
appointment.getIsNew().
appointment.getIsCancelled()
appointment.getIsUnmodified()
</code>
But all above methods return false. I need to find a way to figure out this so that i can sync items from my Exchange Server to my custom application (Note: I am also creating iCal file in my application, so i can use my application when exchange is not connected).
Regards.
you can use the following code to get updated/new meetings.
Date startDate1 = formatter.parse("2014-04-25 07:00:00");
SearchFilter filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.LastModifiedTime,startDate1);
FindItemsResults<Item> findResults = exchange.findItems(WellKnownFolderName.Calendar, filter, new ItemView(10));
for (Item item : findResults.getItems())
{
Appointment appt = (Appointment)item;
System.out.println("SUBJECT====="+appt.getSubject());
System.out.println("Location========"+appt.getLocation());
System.out.println("Start Time========"+appt.getStart());
System.out.println("End Time========"+appt.getEnd());
System.out.println("Email Address========"+ appt.getOrganizer().getAddress());
System.out.println("Last Modified Time========"+appt.getLastModifiedTime());
}

Choose Non-default googlecalendar with google-java-client-api

I want to get all the Calendars, which are in my GoogleAccount, using the google java client API.
In my application I want that a user can choose in wich calendar his events will be saved (not only in the default). But therefore I need their CalendarIDs. I don't want that the users have to search their calendar ids to write them by hand into the app.
Would it be possible to create a new Calendar in his account, to write all the events in this new one.
Sorry for my bad English.
Yes of course it is possible.You only have to know the calendarId in which you want to save the new event, and use them with the event insert function.
For example :
Event event = new Event();
event.setSummary("This is my Event");
event.setLocation("127.0.0.1 -- Home sweet Home!!");
ArrayList<EventAttendee> participants = new ArrayList<EventAttendee>();
participants .add(new EventAttendee().setEmail("member#domain.com"));
event.setAttendees(participants);
DateTime start = new DateTime(new Date(), TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(new Date(startDate.getTime() + 3600000), TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
Event createdEvent = service.events().insert("YourCalendarID", event).execute();
Hope this could help you!

Categories

Resources