Can't connect to (EWS) Public Calendar Folder Java - java

I have created a public calendar folder, but none of the users see it. It should be shared with others.
This is my code:
FolderView fv = new FolderView(50);
fv.setTraversal(FolderTraversal.Deep);
FindFoldersResults f = service.findFolders(WellKnownFolderName.PublicFoldersRoot, fv);
The problem is it throws java.lang.NullPointerException and
microsoft.exchange.webservices.data.EWSHttpException: Connection not established
When I change it to WellKnownFolderName.Root or any other constant like Calendar or Inbox it is working fine. I can review contents with Outlook though.
How can I access public calendar folder with Java if I don't see it and don't know the ID as well?

If you know the email address of the person / resource with the shared folder, then this might work
//Create a inclusive view
FolderView fv = new FolderView(100);
fv.setTraversal(FolderTraversal.Deep);
//Find ID of parent calendar
FolderId sharedFolderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("email.address#of-thing-sharing-calendar"));
//Find children of that calendar
FindFoldersResults findResults = service.findFolders(sharedFolderId, fv);

There is a working example here: Can't connect to (EWS) Public Calendar Folder Java It contains a sample java class that should compile and run, using the Java EWS API

Related

How to empty calendar trash via Google services

How can I empty a trash of a calendar via Google services?
I'm calling google services in Java (com.google.api.services.calendar.Calendar) but I need to empty trash after I deleted events.
I think I have found the only way to solve this problem:
Create a temporary calendar
Move into this calendar all events that I have to delete
Delete the temporary calendar
Like this code:
Calendar entry = new Calendar();
entry.setSummary("MyTrashCalendar");
Calendar result = client.calendars().insert(entry).execute();
...
Event updatedEvent = client.events().move('currentCalendarId', "eventId", "destinationCalendarId").execute();
...
client.calendars().delete(calendar.getId()).execute();
I hope this helps

How to set daily,weakly,monthly,yearly recurrence pattern in calendar(.pst file) using aspose.email for java(jar file)

I am mac os x developer.I have to create .pst file on mac os x machine using java(eclipse).I am using aspose third party jar file (aspose.email for java).But problem with setting monthly recurrence pattern in calendar.
But I found problem is that it shows exception-
 
Duration can't be more than period of recurrence.
****** source code ********
java.util.Calendar calendar = java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
calendar.set(2015, java.util.Calendar.JANUARY, 1,0,0,0);
Date startDate = calendar.getTime();
calendar.set(2016, java.util.Calendar.MARCH, 1,0,0,0);
Date endDate = calendar.getTime();
MapiCalendarEventRecurrence f_reccurence = new MapiCalendarEventRecurrence();
f_reccurence.setRecurrencePattern(new MapiCalendarWeeklyRecurrencePattern());
f_reccurence.getRecurrencePattern().setPatternType(MapiCalendarRecurrencePatternType.Week);
f_reccurence.getRecurrencePattern().setOccurrenceCount(3);
f_reccurence.getRecurrencePattern().setPeriod(2);
f_reccurence.getRecurrencePattern().setEndType(MapiCalendarRecurrenceEndType.NeverEnd);
mapiWeakly = new MapiCalendar("This is Location", "This is Weekly", "This is description",startDate, endDate);
mapiWeakly.setLocation("This is location");
mapiWeakly.setRecurrence(f_reccurence);
We have already investigated this issue posted by you in Aspose.Email forum and feedback has been shared with you in forum. This is actually an issue with the API's recurrence functionality. For further assistance, please follow your thread in Aspose.Email forum.
I work with Aspose as Developer Evangelist.

How to retrieve the event start time in google calendar using the java api?

I have searched a lot and couldnt find the info that i am looking for. I am trying out a google calendar application in google app engine with java. I am unable to figure out how to retrieve the start time of a calendar event. The 'when' field in the CalendarEventEntry class does not exist ( i checked older posts and tried to follow those answers). The getTimes() method returns a list of DateTime entries but i am not sure what those are. Here is a snippet of my code -
CalendarEventFeed resultFeed = service.getFeed(Films_Url, CalendarEventFeed.class);
for (int i = 0; i < resultFeed.getEntries().size(); i++)
{
CalendarEventEntry entry = resultFeed.getEntries().get(i);
Entity Film = new Entity("Films_and_Movies",Film_and_Movie_key);
Film.setProperty("title",entry.getTitle().getPlainText());
Film.setProperty("time",entry.getUpdated().toUiString());
DatastoreService datastorE = DatastoreServiceFactory.getDatastoreService();
datastore.put(Film);
}
entry.getUpdated() does return a DateTime object but it is the time when the event was updated, not the start time. I tried using entry.when.startDate but 'when' does not exist in the CalendarEventEntry class as I said earlier. I tried using EventEntry instead of CalendarEntry but I dont think the former does not exist anymore in recent updates. Can someone please guide me?

Connecting Java with Google Calendar

I'm relatively new to Java, so I have little to no idea where to even start with this one. I'm writing a scheduling application using Java and google calendars. On my google account I have a bunch of calendars with people's schedules on them. I need to access these calendars through java and insert the person's free / busy information into arrays like so:
//User 1
int[][] swift_schedule = new int[5][6];
//1 = busy, 0 = free
//Monday
swift_schedule[0][0] = 0; //9-11
swift_schedule[0][1] = 1; //11-1
swift_schedule[0][2] = 1; //1-3
swift_schedule[0][3] = 1; //3-5
swift_schedule[0][4] = 1; //5-7
swift_schedule[0][5] = 1; //7-9
//Tuesday
swift_schedule[1][0] = 0; //9-11
swift_schedule[1][1] = 0; //11-1
swift_schedule[1][2] = 0; //1-3
etc....
If I were using PHP, I would get a url for the XML feed and just parse the data out of it, but with JAVA I don't even know where to start. Can anyone point me in the right direction? Tutorials, code snippets, and other hints would be greatly appreciated!
cheers,
Mike
You don't have to do the parsing when there is a Java API for it, simply use it and query for the calendar events you want.
With DateTime and CalendarQuery you can query for events in a specific time interval (your use case: to get events in a give day).
CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(DateTime.parseDateTime("2006-03-16T00:00:00"));
myQuery.setMaximumStartTime(DateTime.parseDateTime("2006-03-24T23:59:59"));
Google Calendar allows client
applications to view and update
calendar events in the form of Google
Data API feeds. Your client
application can use the Google
Calendar Data API to create new
events, edit or delete existing
events, and query for events that
match particular criteria.

Get all calendar entries for a given date using Notes.jar

I am working on a simple Java code to extract all calendar entries for a given date. I know it's possible using Domingo but I would like to use only Notes.jar for this purpose. It is possible for me to create a session based on a given credentials and get the calendar object. I am looking to extract the current running Notes session and use that session object to open the calendar view in the mail file and start playing with it. But I am not able to get it working. Anybody have any idea or links on this?
Well I have done with the default notes API and here's the code.
NotesAPITest nat = new NotesAPITest();
NotesThread.sinitThread();
Session sess1 = NotesFactory.createSession();
System.out.println(sess1.getUserName());
Database database = sess1.getDatabase("", "mailfile");
View calendarView = database.getView("($Calendar)");
DateTime dt = sess1.createDateTime("today");
ViewEntryCollection vec = calendarView.getAllEntriesByKey(dt, true);
ViewEntry entry = vec.getFirstEntry();
while (entry != null)
{
Document caldoc = entry.getDocument();
System.out.println("Subject: " + caldoc.getItemValueString("Subject"));
System.out.println("Chair Person: " + caldoc.getItemValueString("Chair"));
System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "StartDateTime") );
System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "EndDateTime") );
System.out.println("Required: " + caldoc.getItemValueString("RequiredAttendees"));
entry = vec.getNextEntry();
}
The only drawback i see is that, whenever the session is extracte, notes pops up a password dialog box. In my searches so far I have not seen a solution for that. Apparently a security arrangement in LN i guess.
Just by googling I have found this article. They create an Eclispe plugin there for Notes. And the example code for getting employee brithdays is also there (I guess Calendar works in a similar way):
s = NotesFactory.createSession();
// Get the local address book
Database nab = s.getDatabase("",s.getAddressBooks().elementAt(0).toString());
if (nab.isOpen() == false) nab.open();
// Get the Birthdays & Anniversaries view
View baview = nab.getView("BA");
ViewEntryCollection eba = baview.getAllEntries();
ViewEntry entry = eba.getFirstEntry();
list = new String[eba.getCount()];
int count = 0;
while (entry != null) {
Vector vals = entry.getColumnValues();
list[count]= vals.elementAt(1).toString() + " " + vals.elementAt(2).toString();
entry = eba.getNextEntry();
count++;
}
EDIT: Also look at this link for some documentation on Notes.jar.
The NotesFactory.createSession() method is what you can use to get a handle to the current session. Notes will automatically share the current client session. If this method is failing, there may be something wrong with your basic configuration. Be sure that:
You have the Notes Client fully installed on the machine running the Java app, and be sure there is a valid Notes ID file. (For example, be sure you can open the Notes client on this machine successfully).
Also, be sure that the the nnotes.dll file is accessible on your machine's path (different than the Java CLASSPATH).
And, confirm that the Notes.ini file is also on the machine's PATH.
#vikramjb, try doing NotesFactory.createSession((String) null, (String) null, password); to prevent the notes password popup from prompting you each time you do something with the session that needs security.
Found out about this from here: http://lekkimworld.com/2006/07/10/java_in_notes_domino_explained_domino_session_tester.html

Categories

Resources