{"action":"created","comment":{"url":"https://api.github.com/repos/openhab/openhab/pulls/comments/44873021","id":44873021,"diff_hunk":"@@ -0,0 +1,348 @@\n+/**\n+ * Copyright (c) 2010-2015, openHAB.org and others.\n+ *\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ */\n+package org.openhab.binding.caldav_personal.internal;\n+\n+\n+import java.util.ArrayList;\n+import java.util.Dictionary;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+import org.joda.time.DateTime;\n+import org.joda.time.format.DateTimeFormat;\n+import org.joda.time.format.DateTimeFormatter;\n+import org.openhab.binding.caldav_personal.CalDavBindingProvider;\n+import org.openhab.binding.caldav_personal.internal.CalDavConfig.Type;\n+\n+import org.openhab.core.binding.AbstractBinding;\n+import org.openhab.core.binding.BindingProvider;\n+import org.openhab.core.library.types.DateTimeType;\n+import org.openhab.core.library.types.OnOffType;\n+import org.openhab.core.library.types.StringType;\n+import org.openhab.core.types.State;\n+import org.openhab.io.caldav.CalDavEvent;\n+import org.openhab.io.caldav.CalDavLoader;\n+import org.openhab.io.caldav.CalDavQuery;\n+import org.openhab.io.caldav.EventNotifier;\n+import org.openhab.io.caldav.CalDavQuery.Sort;\n+import org.osgi.service.cm.ConfigurationException;\n+import org.osgi.service.cm.ManagedService;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\t\n+\n+/**\n+ * Maps events from calDAV to items. Can be used to show personal events in sitemaps.\n+ * \n+ * @author Robert Delbrück\n+ * @since 1.8.0\n+ */\n+public class CalDavBinding extends AbstractBinding<CalDavBindingProvider> implements ManagedService, EventNotifier {\n+\n+\tprivate static final String PARAM_HOME_IDENTIFIERS = \"homeIdentifiers\";\n+    private static final String PARAM_USED_CALENDARS = \"usedCalendars\";\n+\tprivate static final DateTimeFormatter DF = DateTimeFormat.shortDateTime();\n+\tprivate static final DateTimeFormatter FORMATTER = DateTimeFormat.forPattern(\"yyyy-MM-dd'T'HH:mm:ss\");\n+\n+\tprivate static final Logger logger = \n+\t\tLoggerFactory.getLogger(CalDavBinding.class);\n+\t\n+\tprivate CalDavLoader calDavLoader;\n+\t\n+    private List<String> calendars = new ArrayList<String>();\n+\tprivate List<String> homeIdentifier = new ArrayList<String>();\n+\t\n+\tpublic CalDavBinding() {\n+\t}\n+\t\n+\tpublic void setCalDavLoader(CalDavLoader calDavLoader) {\n+\t\tlogger.debug(\"setting CalDavLoader: {}\", calDavLoader != null);\n+\t\tthis.calDavLoader = calDavLoader;\n+\t\tthis.calDavLoader.addListener(this);\n+\t}\n+\t\n+\tpublic void unsetCalDavLoader() {\n+\t\tthis.calDavLoader.removeListener(this);\n+\t\tthis.calDavLoader = null;\n+\t}\n+\t\n+\tpublic void activate() {\n+\t\tlogger.debug(\"CalDavBinding (personal) activated\");\n+\t}\n+\t\n+\tpublic void deactivate() {\n+\t\tif (this.calDavLoader != null) {\n+\t\t\tthis.calDavLoader.removeListener(this);\n+\t\t}\n+\t}\n+\t\n+\t/**\n+\t * {@inheritDoc}\n+\t */\n+\t@Override\n+\tpublic void updated(Dictionary<String, ?> properties)\n+\t\t\tthrows ConfigurationException {\n+\t\tif (properties != null) {\n+\t\t\tlogger.debug(\"loading configuration...\");\n+\t\t\tString usedCalendars = (String) properties\n+\t\t\t\t\t.get(PARAM_USED_CALENDARS);\n+\t\t\tif (usedCalendars != null) {\n+\t\t\t\tfor (String cal : usedCalendars.split(\",\")) {\n+\t\t\t\t\tthis.calendars.add(cal.trim());\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tString homeIdentifiers = (String) properties\n+\t\t\t\t\t.get(PARAM_HOME_IDENTIFIERS);\n+\t\t\tif (homeIdentifiers != null) {\n+\t\t\t\tfor (String homeIdent : homeIdentifiers.split(\",\")) {\n+\t\t\t\t\tthis.homeIdentifier.add(homeIdent.trim().toLowerCase());\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tlogger.debug(\"loading configuration done\");\n+\t\t\tthis.reloadCurrentLoadedEvents();\n+\t\t}\n+\t\t\n+\t}\n+\t\n+\tprivate void reloadCurrentLoadedEvents() {\n+\t\ttry {\n+\t\t\tif (this.calDavLoader == null) {\n+\t\t\t\treturn;\n+\t\t\t}\n+\t\t\tlogger.trace(\"reloading events\");\n+\t\t\tfor (String calendarKey : this.calendars) {\n+\t\t\t\tcalendarReloaded(calendarKey);\n+\t\t\t}\n+\t\t} catch (Exception e) {\n+\t\t\tlogger.error(\"cannot load events\", e);\n+\t\t}\n+\t}\n+\t\n+\t@Override\n+\tpublic void allBindingsChanged(BindingProvider provider) {\n+\t\tthis.updateItemsForEvent();\n+\t}\n+\n+\t@Override\n+\tpublic void bindingChanged(BindingProvider provider, String itemName) {\n+\t\tif (!(provider instanceof CalDavBindingProvider)) {\n+\t\t\treturn;\n+\t\t}\n+\t\tCalDavConfig config = ((CalDavBindingProvider) provider).getConfig(itemName);\n+\t\tif (config == null) {\n+\t\t\treturn;\n+\t\t}\n+\t\tfinal List<CalDavEvent> events = this.calDavLoader.getEvents(new CalDavQuery(this.calendars, DateTime.now(), Sort.ASCENDING));\n+\t\tthis.updateItem(itemName, config, events);\n+\t}\n+\t\n+\t\n+\t/**\n+\t * {@inheritDoc}\n+\t */\n+\t@Override\n+\tpublic void eventRemoved(CalDavEvent event) {\n+\t}\n+\n+\t/**\n+\t * {@inheritDoc}\n+\t */\n+\t@Override\n+\tpublic void eventLoaded(CalDavEvent event) {\n+\t}\n+\t\n+\t/**\n+\t * {@inheritDoc}\n+\t */\n+\t@Override\n+\tpublic void eventBegins(CalDavEvent event) {","path":"bundles/binding/org.openhab.binding.caldav-personal/src/main/java/org/openhab/binding/caldav_personal/internal/CalDavBinding.java","position":166,"original_position":166,"commit_id":"e260d69e7d2d40ab5f149fa927953a344ab7aa8e","original_commit_id":"e260d69e7d2d40ab5f149fa927953a344ab7aa8e","user":{"login":"hakan42","id":352641,"avatar_url":"https://avatars.githubusercontent.com/u/352641?v=3","gravatar_id":"","url":"https://api.github.com/users/hakan42","html_url":"https://github.com/hakan42","followers_url":"https://api.github.com/users/hakan42/followers","following_url":"https://api.github.com/users/hakan42/following{/other_user}","gists_url":"https://api.github.com/users/hakan42/gists{/gist_id}","starred_url":"https://api.github.com/users/hakan42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hakan42/subscriptions","organizations_url":"https://api.github.com/users/hakan42/orgs","repos_url":"https://api.github.com/users/hakan42/repos","events_url":"https://api.github.com/users/hakan42/events{/privacy}","received_events_url":"https://api.github.com/users/hakan42/received_events","type":"User","site_admin":false},"body":"tabs vs. spaces in this complete file?","created_at":"2015-11-15T15:28:52Z","updated_at":"2015-11-15T15:28:52Z","html_url":"https://github.com/openhab/openhab/pull/3422#discussion_r44873021","pull_request_url":"https://api.github.com/repos/openhab/openhab/pulls/3422","_links":{"self":{"href":"https://api.github.com/repos/openhab/openhab/pulls/comments/44873021"},"html":{"href":"https://github.com/openhab/openhab/pull/3422#discussion_r44873021"},"pull_request":{"href":"https://api.github.com/repos/openhab/openhab/pulls/3422"}}},"pull_request":{"url":"https://api.github.com/repos/openhab/openhab/pulls/3422","id":50743846,"html_url":"https://github.com/openhab/openhab/pull/3422","diff_url":"https://github.com/openhab/openhab/pull/3422.diff","patch_url":"https://github.com/openhab/openhab/pull/3422.patch","issue_url":"https://api.github.com/repos/openhab/openhab/issues/3422","number":3422,"state":"open","locked":false,"title":"caldav binding 15/11","user":{"login":"querdenker2k","id":6350333,"avatar_url":"https://avatars.githubusercontent.com/u/6350333?v=3","gravatar_id":"","url":"https://api.github.com/users/querdenker2k","html_url":"https://github.com/querdenker2k","followers_url":"https://api.github.com/users/querdenker2k/followers","following_url":"https://api.github.com/users/querdenker2k/following{/other_user}","gists_url":"https://api.github.com/users/querdenker2k/gists{/gist_id}","starred_url":"https://api.github.com/users/querdenker2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/querdenker2k/subscriptions","organizations_url":"https://api.github.com/users/querdenker2k/orgs","repos_url":"https://api.github.com/users/querdenker2k/repos","events_url":"https://api.github.com/users/querdenker2k/events{/privacy}","received_events_url":"https://api.github.com/users/querdenker2k/received_events","type":"User","site_admin":false},"body":"PR for caldav-binding in one commit","created_at":"2015-11-15T10:17:36Z","updated_at":"2015-11-15T15:28:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e27e3dfe96451b3793adf8a28feccc111e9b607b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openhab/openhab/pulls/3422/commits","review_comments_url":"https://api.github.com/repos/openhab/openhab/pulls/3422/comments","review_comment_url":"https://api.github.com/repos/openhab/openhab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openhab/openhab/issues/3422/comments","statuses_url":"https://api.github.com/repos/openhab/openhab/statuses/e260d69e7d2d40ab5f149fa927953a344ab7aa8e","head":{"label":"querdenker2k:caldav-15-11","ref":"caldav-15-11","sha":"e260d69e7d2d40ab5f149fa927953a344ab7aa8e","user":{"login":"querdenker2k","id":6350333,"avatar_url":"https://avatars.githubusercontent.com/u/6350333?v=3","gravatar_id":"","url":"https://api.github.com/users/querdenker2k","html_url":"https://github.com/querdenker2k","followers_url":"https://api.github.com/users/querdenker2k/followers","following_url":"https://api.github.com/users/querdenker2k/following{/other_user}","gists_url":"https://api.github.com/users/querdenker2k/gists{/gist_id}","starred_url":"https://api.github.com/users/querdenker2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/querdenker2k/subscriptions","organizations_url":"https://api.github.com/users/querdenker2k/orgs","repos_url":"https://api.github.com/users/querdenker2k/repos","events_url":"https://api.github.com/users/querdenker2k/events{/privacy}","received_events_url":"https://api.github.com/users/querdenker2k/received_events","type":"User","site_admin":false},"repo":{"id":30401626,"name":"openhab","full_name":"querdenker2k/openhab","owner":{"login":"querdenker2k","id":6350333,"avatar_url":"https://avatars.githubusercontent.com/u/6350333?v=3","gravatar_id":"","url":"https://api.github.com/users/querdenker2k","html_url":"https://github.com/querdenker2k","followers_url":"https://api.github.com/users/querdenker2k/followers","following_url":"https://api.github.com/users/querdenker2k/following{/other_user}","gists_url":"https://api.github.com/users/querdenker2k/gists{/gist_id}","starred_url":"https://api.github.com/users/querdenker2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/querdenker2k/subscriptions","organizations_url":"https://api.github.com/users/querdenker2k/orgs","repos_url":"https://api.github.com/users/querdenker2k/repos","events_url":"https://api.github.com/users/querdenker2k/events{/privacy}","received_events_url":"https://api.github.com/users/querdenker2k/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/querdenker2k/openhab","description":"Source code of the open Home Automation Bus (openHAB)","fork":true,"url":"https://api.github.com/repos/querdenker2k/openhab","forks_url":"https://api.github.com/repos/querdenker2k/openhab/forks","keys_url":"https://api.github.com/repos/querdenker2k/openhab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/querdenker2k/openhab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/querdenker2k/openhab/teams","hooks_url":"https://api.github.com/repos/querdenker2k/openhab/hooks","issue_events_url":"https://api.github.com/repos/querdenker2k/openhab/issues/events{/number}","events_url":"https://api.github.com/repos/querdenker2k/openhab/events","assignees_url":"https://api.github.com/repos/querdenker2k/openhab/assignees{/user}","branches_url":"https://api.github.com/repos/querdenker2k/openhab/branches{/branch}","tags_url":"https://api.github.com/repos/querdenker2k/openhab/tags","blobs_url":"https://api.github.com/repos/querdenker2k/openhab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/querdenker2k/openhab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/querdenker2k/openhab/git/refs{/sha}","trees_url":"https://api.github.com/repos/querdenker2k/openhab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/querdenker2k/openhab/statuses/{sha}","languages_url":"https://api.github.com/repos/querdenker2k/openhab/languages","stargazers_url":"https://api.github.com/repos/querdenker2k/openhab/stargazers","contributors_url":"https://api.github.com/repos/querdenker2k/openhab/contributors","subscribers_url":"https://api.github.com/repos/querdenker2k/openhab/subscribers","subscription_url":"https://api.github.com/repos/querdenker2k/openhab/subscription","commits_url":"https://api.github.com/repos/querdenker2k/openhab/commits{/sha}","git_commits_url":"https://api.github.com/repos/querdenker2k/openhab/git/commits{/sha}","comments_url":"https://api.github.com/repos/querdenker2k/openhab/comments{/number}","issue_comment_url":"https://api.github.com/repos/querdenker2k/openhab/issues/comments{/number}","contents_url":"https://api.github.com/repos/querdenker2k/openhab/contents/{+path}","compare_url":"https://api.github.com/repos/querdenker2k/openhab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/querdenker2k/openhab/merges","archive_url":"https://api.github.com/repos/querdenker2k/openhab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/querdenker2k/openhab/downloads","issues_url":"https://api.github.com/repos/querdenker2k/openhab/issues{/number}","pulls_url":"https://api.github.com/repos/querdenker2k/openhab/pulls{/number}","milestones_url":"https://api.github.com/repos/querdenker2k/openhab/milestones{/number}","notifications_url":"https://api.github.com/repos/querdenker2k/openhab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/querdenker2k/openhab/labels{/name}","releases_url":"https://api.github.com/repos/querdenker2k/openhab/releases{/id}","created_at":"2015-02-06T07:59:43Z","updated_at":"2015-05-05T14:52:35Z","pushed_at":"2015-11-15T10:15:11Z","git_url":"git://github.com/querdenker2k/openhab.git","ssh_url":"git@github.com:querdenker2k/openhab.git","clone_url":"https://github.com/querdenker2k/openhab.git","svn_url":"https://github.com/querdenker2k/openhab","homepage":null,"size":162942,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openhab:master","ref":"master","sha":"689ce4b575807d0c34febe9b158338c1c7b4eb66","user":{"login":"openhab","id":1007353,"avatar_url":"https://avatars.githubusercontent.com/u/1007353?v=3","gravatar_id":"","url":"https://api.github.com/users/openhab","html_url":"https://github.com/openhab","followers_url":"https://api.github.com/users/openhab/followers","following_url":"https://api.github.com/users/openhab/following{/other_user}","gists_url":"https://api.github.com/users/openhab/gists{/gist_id}","starred_url":"https://api.github.com/users/openhab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openhab/subscriptions","organizations_url":"https://api.github.com/users/openhab/orgs","repos_url":"https://api.github.com/users/openhab/repos","events_url":"https://api.github.com/users/openhab/events{/privacy}","received_events_url":"https://api.github.com/users/openhab/received_events","type":"Organization","site_admin":false},"repo":{"id":12983151,"name":"openhab","full_name":"openhab/openhab","owner":{"login":"openhab","id":1007353,"avatar_url":"https://avatars.githubusercontent.com/u/1007353?v=3","gravatar_id":"","url":"https://api.github.com/users/openhab","html_url":"https://github.com/openhab","followers_url":"https://api.github.com/users/openhab/followers","following_url":"https://api.github.com/users/openhab/following{/other_user}","gists_url":"https://api.github.com/users/openhab/gists{/gist_id}","starred_url":"https://api.github.com/users/openhab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openhab/subscriptions","organizations_url":"https://api.github.com/users/openhab/orgs","repos_url":"https://api.github.com/users/openhab/repos","events_url":"https://api.github.com/users/openhab/events{/privacy}","received_events_url":"https://api.github.com/users/openhab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openhab/openhab","description":"Source code of the open Home Automation Bus (openHAB)","fork":false,"url":"https://api.github.com/repos/openhab/openhab","forks_url":"https://api.github.com/repos/openhab/openhab/forks","keys_url":"https://api.github.com/repos/openhab/openhab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openhab/openhab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openhab/openhab/teams","hooks_url":"https://api.github.com/repos/openhab/openhab/hooks","issue_events_url":"https://api.github.com/repos/openhab/openhab/issues/events{/number}","events_url":"https://api.github.com/repos/openhab/openhab/events","assignees_url":"https://api.github.com/repos/openhab/openhab/assignees{/user}","branches_url":"https://api.github.com/repos/openhab/openhab/branches{/branch}","tags_url":"https://api.github.com/repos/openhab/openhab/tags","blobs_url":"https://api.github.com/repos/openhab/openhab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openhab/openhab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openhab/openhab/git/refs{/sha}","trees_url":"https://api.github.com/repos/openhab/openhab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openhab/openhab/statuses/{sha}","languages_url":"https://api.github.com/repos/openhab/openhab/languages","stargazers_url":"https://api.github.com/repos/openhab/openhab/stargazers","contributors_url":"https://api.github.com/repos/openhab/openhab/contributors","subscribers_url":"https://api.github.com/repos/openhab/openhab/subscribers","subscription_url":"https://api.github.com/repos/openhab/openhab/subscription","commits_url":"https://api.github.com/repos/openhab/openhab/commits{/sha}","git_commits_url":"https://api.github.com/repos/openhab/openhab/git/commits{/sha}","comments_url":"https://api.github.com/repos/openhab/openhab/comments{/number}","issue_comment_url":"https://api.github.com/repos/openhab/openhab/issues/comments{/number}","contents_url":"https://api.github.com/repos/openhab/openhab/contents/{+path}","compare_url":"https://api.github.com/repos/openhab/openhab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openhab/openhab/merges","archive_url":"https://api.github.com/repos/openhab/openhab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openhab/openhab/downloads","issues_url":"https://api.github.com/repos/openhab/openhab/issues{/number}","pulls_url":"https://api.github.com/repos/openhab/openhab/pulls{/number}","milestones_url":"https://api.github.com/repos/openhab/openhab/milestones{/number}","notifications_url":"https://api.github.com/repos/openhab/openhab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openhab/openhab/labels{/name}","releases_url":"https://api.github.com/repos/openhab/openhab/releases{/id}","created_at":"2013-09-20T20:28:43Z","updated_at":"2015-11-15T14:15:04Z","pushed_at":"2015-11-15T10:17:37Z","git_url":"git://github.com/openhab/openhab.git","ssh_url":"git@github.com:openhab/openhab.git","clone_url":"https://github.com/openhab/openhab.git","svn_url":"https://github.com/openhab/openhab","homepage":null,"size":296929,"stargazers_count":1837,"watchers_count":1837,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1030,"mirror_url":null,"open_issues_count":522,"forks":1030,"open_issues":522,"watchers":1837,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openhab/openhab/pulls/3422"},"html":{"href":"https://github.com/openhab/openhab/pull/3422"},"issue":{"href":"https://api.github.com/repos/openhab/openhab/issues/3422"},"comments":{"href":"https://api.github.com/repos/openhab/openhab/issues/3422/comments"},"review_comments":{"href":"https://api.github.com/repos/openhab/openhab/pulls/3422/comments"},"review_comment":{"href":"https://api.github.com/repos/openhab/openhab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openhab/openhab/pulls/3422/commits"},"statuses":{"href":"https://api.github.com/repos/openhab/openhab/statuses/e260d69e7d2d40ab5f149fa927953a344ab7aa8e"}}}}