How to get shared calendar list using caldav4j from davical? - java

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.

Related

Check for conflict when booking an event on Microsoft calendar

I am using the following code to create events on a microsoft account calendar:
Event event = new Event();
event.subject = meetingType.getName();
event.body = getMicrosoftMeetingBody(meetingType);
event.start = getMicrosoftMeetingStart(timeSlot);
event.end = getMicrosoftMeetingEnd(timeSlot, meetingType);
event.location = getMicrosoftMeetingLocation();
event.attendees = getMicrosoftMeetingAttendeeList(attendeeName, attendeeEmail);
event.isOnlineMeeting = true;
event.onlineMeetingProvider = OnlineMeetingProviderType.TEAMS_FOR_BUSINESS;
event.reminderMinutesBeforeStart = SIXTY_MINUTES;
event.responseRequested = true;
Event createdEvent = graphClient.me().calendars(userCalendar.getCalendarId()).events()
.buildRequest()
.post(event);
The above code works and is creating events on the calendar. However, it double books a slot even if there are pre-existing events on it.
Is it possible to build a request in such a way so as to not do the booking if the slot is already booked?

Not getting invite acceptation email in ical4j

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.

Paypal SDK set billing plan to active

I am new to the PayPal SDK and I am trying to create a billing plan and change its status to ACTIVE. I have tried some sample Java code from the SDK tutorial but I can't get that code to work. Status remains CREATED. The code I tried can be found below.
What is missing/wrong?
The output from running the code is
Created plan with id = P-1MT21723NA428154CRJGOTXQ
Plan state = CREATED
Plan state = CREATED
Best regards /Lasse
// Build Plan object
Plan plan = new Plan();
plan.setName("T-Shirt of the Month Club Plan");
plan.setDescription("Template creation.");
plan.setType("fixed");
// Payment_definitions
PaymentDefinition paymentDefinition = new PaymentDefinition();
paymentDefinition.setName("Regular Payments");
paymentDefinition.setType("REGULAR");
paymentDefinition.setFrequency("MONTH");
paymentDefinition.setFrequencyInterval("1");
paymentDefinition.setCycles("12");
// Currency
Currency currency = new Currency();
currency.setCurrency("USD");
currency.setValue("20");
paymentDefinition.setAmount(currency);
// Charge_models
ChargeModels chargeModels = new ChargeModels();
chargeModels.setType("SHIPPING");
chargeModels.setAmount(currency);
List<ChargeModels> chargeModelsList = new ArrayList<>();
chargeModelsList.add(chargeModels);
paymentDefinition.setChargeModels(chargeModelsList);
// Payment_definition
List<PaymentDefinition> paymentDefinitionList = new ArrayList<>();
paymentDefinitionList.add(paymentDefinition);
plan.setPaymentDefinitions(paymentDefinitionList);
// Merchant_preferences
MerchantPreferences merchantPreferences = new MerchantPreferences();
merchantPreferences.setSetupFee(currency);
merchantPreferences.setCancelUrl("https://example.com/cancel");
merchantPreferences.setReturnUrl("https://example.com/return");
merchantPreferences.setMaxFailAttempts("0");
merchantPreferences.setAutoBillAmount("YES");
merchantPreferences.setInitialFailAmountAction("CONTINUE");
plan.setMerchantPreferences(merchantPreferences);
// Create payment
Plan createdPlan = plan.create(apiContext);
System.out.println("Created plan with id = " + createdPlan.getId());
System.out.println("Plan state = " + createdPlan.getState());
// Set up plan activate PATCH request
List<Patch> patchRequestList = new ArrayList<>();
Map<String, String> value = new HashMap<>();
value.put("state", "ACTIVE");
// Create update object to activate plan
Patch patch = new Patch();
patch.setPath("/");
patch.setValue(value);
patch.setOp("replace");
patchRequestList.add(patch);
// Activate plan
createdPlan.update(apiContext, patchRequestList);
System.out.println("Plan state = " + createdPlan.getState());
Got it!
I had to execute Plan.get(context, createdPlan.getId());
to get the latest state of the plan.

Creating Meeting lotus Meeting using ICall

In a eclipse plugin for the Lotus Notes client I need to create a meeting in a user's mailfile. I have created successfully an appointment in my own mailfile using the NotesCalendar object. (see code below ). What I don't seem to get right is to create a meeting instead of an appointment. On the database level the difference is made by a field called appointmenttype which is set to 3 in the case of a meeting and 0 in the case of a appointment.
According to resources I found I need to add the xProperty "X-LOTUS-APPTTYPE" with a value of "3" to my Ical4j object but for some reason this is not being processed by the NotesCalendar.createEntry() method.
Does someone have any idea how to create a Meeting in a mailfile using the NotesCalendar notes classes and Ical4j?
(the reason I have added the xPages tag is that I hope someone in the xPages community ever has used the notescalendar objects before )
Code that creates an appointment:
DateTime meetingStart = new DateTime(c.getStartTime().getTime());
DateTime meetingEnd = new DateTime(c.getEndTime().getTime());
VEvent meeting = new VEvent(meetingStart, meetingEnd, c.getSubject());
// Add chair
Attendee chairAttendee = new Attendee(URI.create("mailto:j.somhorst#development.acuity.nl"));
chairAttendee.getParameters().add(Role.CHAIR);
// Add invitees
for(User invitee : c.getUserParticipants()){
Attendee attendee = new Attendee(URI.create("mailto:"+invitee.getEmail()));
attendee.getParameters().add(Role.REQ_PARTICIPANT);
meeting.getProperties().add(attendee);
}
// create calendar for ics export
Calendar call = new Calendar();
call.getProperties().add(new ProdId("-//Lotus Development Corporation//NONSGML Notes 9.0.1//EN_API_C"));
call.getComponents().add(meeting);
// notes specific fields
meeting.getProperties().add(new XProperty("X-LOTUS-NOTESVERSION","2"));
meeting.getProperties().add(new XProperty("X-LOTUS-APPTTYPE","3"));
NotesCalendar notesCalendar = NotesUtil.getNotesCalendar(s);
if(notesCalendar!=null){
notesCalendar.setAutoSendNotices(false);
NotesCalendarEntry entry = notesCalendar.createEntry(call.toString());
String icallvalue = entry.read();
System.out.println(icallvalue);
}

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());
}

Categories

Resources