.entrySet()) {
repository.addDataSource(curSettingEntry.getKey(), Events.class,
new EventsImpl(curSettingEntry.getKey(), this));
if (curSettingEntry.getKey() instanceof AbstractCodeNameKey) {
AbstractCodeNameKey colorkey = ((AbstractCodeNameKey) curSettingEntry
.getKey());
if (colorkey.getColor() == null) {
try {
Map<String, ?> googleSettingsForProject = curSettingEntry
.getValue();
String username = googleSettingsForProject.get(
"username").toString();
String password = googleSettingsForProject.get(
"password").toString();
String calendarId = googleSettingsForProject.get(
"calendarId").toString();
CalendarService service = new CalendarService(
"Dashboard");
service.setUserCredentials(username, password);
CalendarQuery calendarQuery = new CalendarQuery(
new URL(
"https://www.google.com/calendar/feeds/default/owncalendars/full"));
CalendarFeed calendarFeed = service.query(
calendarQuery, CalendarFeed.class);
for (CalendarEntry curCalendar : calendarFeed
.getEntries()) {
if (curCalendar.getId().endsWith(
calendarId.replaceAll("@", "%40"))
&& curCalendar.getColor() != null) {
colorkey.setColor(curCalendar.getColor()
.getValue());
break;
}
}