{"action":"created","comment":{"url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/comments/63751124","id":63751124,"diff_hunk":"@@ -0,0 +1,74 @@\n+package io.commercetools.sunrise.cms;\n+\n+import javax.annotation.Nullable;\n+\n+import static org.apache.commons.lang3.StringUtils.split;\n+\n+/**\n+ * CMS Identifier, consisting of the field name and the content type and key.\n+ *\n+ * - {@code entryType}: type of entry which usually defines the fields it can contain (e.g. banner)\n+ * - {@code entryKey}: key that identifies the particular entry (e.g. homeTopLeft)\n+ * - {@code fieldName}: field name of the required content (e.g. subtitle)\n+ *\n+ * @see CmsService\n+ */\n+public final class CmsIdentifier {\n+\n+    private final String entryType;\n+    private final String entryKey;\n+    private final String fieldName;\n+\n+    private CmsIdentifier(final String entryType, final String entryKey, final String fieldName) {\n+        this.entryType = entryType;\n+        this.entryKey = entryKey;\n+        this.fieldName = fieldName;\n+    }\n+\n+    public String getEntryType() {\n+        return entryType;\n+    }\n+\n+    public String getEntryKey() {\n+        return entryKey;\n+    }\n+\n+    public String getFieldName() {\n+        return fieldName;\n+    }\n+\n+    /**\n+     * Creates a CMS Identifier, consisting of the field name and the entry type and key.\n+     * @param entryWithField of the form {@code entryType:entryKey.fieldName}\n+     * @return the CMS Identifier for the given input\n+     */\n+    public static CmsIdentifier of(final String entryWithField) {\n+        final String[] parts = split(entryWithField, \":\", 2);\n+        final String contentType = getArrayElement(parts, 0, \"\");\n+        final String content = getArrayElement(parts, 1, entryWithField);\n+\n+        final String[] contentParts = split(content, \".\", 2);\n+        final String contentId = getArrayElement(contentParts, 0, \"\");\n+        final String field = getArrayElement(contentParts, 1, \"\");\n+\n+        return ofEntryTypeAndKeyAndField(contentType, contentId, field);\n+    }\n+\n+    public static CmsIdentifier ofEntryTypeAndKeyAndField(final String entryType, final String entryKey, final String fieldName) {\n+        return new CmsIdentifier(entryType, entryKey, fieldName);\n+    }\n+\n+    /**\n+     * Given a string array and a particular position, it returns the array element in that position\n+     * or the default value if the array does not contain an element for that position.\n+     * @param array the string array from which to get the element\n+     * @param position the position of the element\n+     * @param defaultValue the default value returned in case there is no element in that position\n+     * @return the element from the array in that position, or the default value if there is no element\n+     */\n+    @Nullable\n+    public static String getArrayElement(final String[] array, final int position, final String defaultValue) {","path":"cms-common/src/main/java/io/commercetools/sunrise/cms/CmsIdentifier.java","position":70,"original_position":70,"commit_id":"a1ba0f955c7178b85271ee48dbcefaa720449ec5","original_commit_id":"a1ba0f955c7178b85271ee48dbcefaa720449ec5","user":{"login":"schleichardt","id":1320833,"avatar_url":"https://avatars.githubusercontent.com/u/1320833?v=3","gravatar_id":"","url":"https://api.github.com/users/schleichardt","html_url":"https://github.com/schleichardt","followers_url":"https://api.github.com/users/schleichardt/followers","following_url":"https://api.github.com/users/schleichardt/following{/other_user}","gists_url":"https://api.github.com/users/schleichardt/gists{/gist_id}","starred_url":"https://api.github.com/users/schleichardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schleichardt/subscriptions","organizations_url":"https://api.github.com/users/schleichardt/orgs","repos_url":"https://api.github.com/users/schleichardt/repos","events_url":"https://api.github.com/users/schleichardt/events{/privacy}","received_events_url":"https://api.github.com/users/schleichardt/received_events","type":"User","site_admin":false},"body":"I don't see where this has sth. to do with CMS.","created_at":"2016-05-18T17:57:10Z","updated_at":"2016-05-18T17:57:10Z","html_url":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1#discussion_r63751124","pull_request_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/comments/63751124"},"html":{"href":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1#discussion_r63751124"},"pull_request":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1","id":70569284,"html_url":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1","diff_url":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1.diff","patch_url":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1.patch","issue_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/1","number":1,"state":"closed","locked":false,"title":"Add common dependencies","user":{"login":"lauraluiz","id":1917621,"avatar_url":"https://avatars.githubusercontent.com/u/1917621?v=3","gravatar_id":"","url":"https://api.github.com/users/lauraluiz","html_url":"https://github.com/lauraluiz","followers_url":"https://api.github.com/users/lauraluiz/followers","following_url":"https://api.github.com/users/lauraluiz/following{/other_user}","gists_url":"https://api.github.com/users/lauraluiz/gists{/gist_id}","starred_url":"https://api.github.com/users/lauraluiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lauraluiz/subscriptions","organizations_url":"https://api.github.com/users/lauraluiz/orgs","repos_url":"https://api.github.com/users/lauraluiz/repos","events_url":"https://api.github.com/users/lauraluiz/events{/privacy}","received_events_url":"https://api.github.com/users/lauraluiz/received_events","type":"User","site_admin":false},"body":"/cc @schleichardt \r\nNot very happy with the apache commons dependency for just a method. But since it's CMS, maybe we will be needing this library more.","created_at":"2016-05-18T17:37:35Z","updated_at":"2016-05-18T17:57:10Z","closed_at":"2016-05-18T17:40:44Z","merged_at":"2016-05-18T17:40:44Z","merge_commit_sha":"c7173d6b24fb580df8358a59d1e9079e176ce4d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1/commits","review_comments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1/comments","review_comment_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/1/comments","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/statuses/a1ba0f955c7178b85271ee48dbcefaa720449ec5","head":{"label":"commercetools:common-dep","ref":"common-dep","sha":"a1ba0f955c7178b85271ee48dbcefaa720449ec5","user":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars.githubusercontent.com/u/1084585?v=3","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":59130746,"name":"commercetools-sunrise-java-cms","full_name":"commercetools/commercetools-sunrise-java-cms","owner":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars.githubusercontent.com/u/1084585?v=3","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/commercetools/commercetools-sunrise-java-cms","description":"Module for Sunrise Java to use CMS","fork":false,"url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms","forks_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/forks","keys_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/teams","hooks_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/hooks","issue_events_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/events","assignees_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/tags","blobs_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/languages","stargazers_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/stargazers","contributors_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/contributors","subscribers_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/subscribers","subscription_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/subscription","commits_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/merges","archive_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/downloads","issues_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/deployments","created_at":"2016-05-18T15:58:30Z","updated_at":"2016-05-18T17:40:45Z","pushed_at":"2016-05-18T17:56:46Z","git_url":"git://github.com/commercetools/commercetools-sunrise-java-cms.git","ssh_url":"git@github.com:commercetools/commercetools-sunrise-java-cms.git","clone_url":"https://github.com/commercetools/commercetools-sunrise-java-cms.git","svn_url":"https://github.com/commercetools/commercetools-sunrise-java-cms","homepage":"","size":39,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"commercetools:master","ref":"master","sha":"4b3fa80f236db2811d5881040acf2a96b9c5aa51","user":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars.githubusercontent.com/u/1084585?v=3","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":59130746,"name":"commercetools-sunrise-java-cms","full_name":"commercetools/commercetools-sunrise-java-cms","owner":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars.githubusercontent.com/u/1084585?v=3","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/commercetools/commercetools-sunrise-java-cms","description":"Module for Sunrise Java to use CMS","fork":false,"url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms","forks_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/forks","keys_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/teams","hooks_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/hooks","issue_events_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/events","assignees_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/tags","blobs_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/languages","stargazers_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/stargazers","contributors_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/contributors","subscribers_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/subscribers","subscription_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/subscription","commits_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/merges","archive_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/downloads","issues_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/deployments","created_at":"2016-05-18T15:58:30Z","updated_at":"2016-05-18T17:40:45Z","pushed_at":"2016-05-18T17:56:46Z","git_url":"git://github.com/commercetools/commercetools-sunrise-java-cms.git","ssh_url":"git@github.com:commercetools/commercetools-sunrise-java-cms.git","clone_url":"https://github.com/commercetools/commercetools-sunrise-java-cms.git","svn_url":"https://github.com/commercetools/commercetools-sunrise-java-cms","homepage":"","size":39,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1"},"html":{"href":"https://github.com/commercetools/commercetools-sunrise-java-cms/pull/1"},"issue":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/1"},"comments":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/commercetools/commercetools-sunrise-java-cms/statuses/a1ba0f955c7178b85271ee48dbcefaa720449ec5"}}}}