{"action":"created","comment":{"url":"https://api.github.com/repos/celements/celements-course/pulls/comments/81800612","pull_request_review_id":2750537,"id":81800612,"diff_hunk":"@@ -63,6 +98,119 @@ public String getCourseTypeName(DocumentReference courseTypeDocRef\n     return typeName;\n   }\n \n+  @Override\n+  public boolean registerParticipantFromRequest(boolean sendConfirmationMail) {\n+    XWikiRequest req = getContext().getRequest();\n+    RegistrationData data = new RegistrationData();\n+    data.setData(req);\n+    data.setRegDocRef(nextFreeDoc.getNextUntitledPageDocRef(getSpaceForEventId(data.getEventid())));\n+    try {\n+      XWikiDocument regDoc = modelAccess.createDocument(data.getRegDocRef());\n+      setMandatoryRegSpaceDocs(regDoc);\n+      DocumentReference classRef = getCourseClasses().getCourseParticipantClassRef(\n+          modelContext.getWikiRef().getName());\n+      for (Person person : data.getPersons()) {\n+        if (!person.isEmpty() || (modelAccess.getXObjects(regDoc, classRef).size() == 0)) {\n+          BaseObject obj = modelAccess.newXObject(regDoc, classRef);\n+          obj.setStringValue(\"eventid\", data.getEventid());\n+          obj.setStringValue(\"title\", person.getTitle());\n+          obj.setStringValue(\"firstname\", person.getGivenName());\n+          obj.setStringValue(\"lastname\", person.getSurname());\n+          obj.setStringValue(\"address\", person.getAddress());\n+          obj.setStringValue(\"zip\", person.getZip());\n+          obj.setStringValue(\"city\", person.getCity());\n+          obj.setStringValue(\"phone\", person.getPhone());\n+          obj.setStringValue(\"email\", normalizeEmail(person.getEmail()));\n+          obj.setDateValue(\"dob\", person.getDateOfBirth());\n+          obj.setStringValue(\"status\", person.getStatus());\n+          if (obj.getNumber() == 0) {\n+            obj.setLargeStringValue(\"comment\", data.getComment());\n+            // using set since there is no setPassword method\n+            obj.set(\"validkey\", data.getValidationKey(), getContext());\n+            obj.setDateValue(\"timestamp\", new Date());\n+            obj.setStringValue(\"client\", getClientInfo());\n+          }\n+        }\n+      }\n+      modelAccess.saveDocument(regDoc, \"created new registration\");\n+      if (sendConfirmationMail) {\n+        sendConfirmationMail(data);\n+      }\n+      return true;\n+    } catch (DocumentAlreadyExistsException | DocumentSaveException | XWikiException excp) {\n+      LOGGER.error(\"exception while creating new registration\", excp);\n+    }\n+    return false;\n+  }\n+\n+  void setMandatoryRegSpaceDocs(XWikiDocument regDoc) {\n+    if (regDoc.isNew()) {\n+      SpaceReference regSpace = regDoc.getDocumentReference().getLastSpaceReference();\n+      DocumentReference webPrefRef = new DocumentReference(\"WebPreferences\", regSpace);\n+      if (!modelAccess.exists(webPrefRef)) {\n+        DocumentReference globalRightsRef = new DocumentReference(\"XWikiGlobalRights\",\n+            new SpaceReference(\"XWiki\", modelContext.getWikiRef()));\n+        XWikiDocument webPrefDoc = modelAccess.getOrCreateDocument(webPrefRef);\n+        BaseObject rightsObj = modelAccess.newXObject(webPrefDoc, globalRightsRef);\n+        modelAccess.setProperty(rightsObj, \"groups\", \"XWiki.XWikiAdminGroup\");\n+        modelAccess.setProperty(rightsObj, \"levels\", \"view,edit,delete,undelete\");\n+        modelAccess.setProperty(rightsObj, \"users\", \"\");\n+        modelAccess.setProperty(rightsObj, \"allow\", 1);\n+        try {\n+          modelAccess.saveDocument(webPrefDoc, \"createdAndSetContent\");\n+        } catch (DocumentSaveException dse) {\n+          LOGGER.error(\"Exception saving registration space WebPreferences document.\", dse);\n+        }\n+      }\n+      DocumentReference webHomeRef = new DocumentReference(\"WebHome\", regSpace);\n+      if (!modelAccess.exists(webHomeRef)) {\n+        XWikiDocument webHomeDoc = modelAccess.getOrCreateDocument(webHomeRef);\n+        webHomeDoc.setContent(\"#parse('celMacros/getRegistrationListing.vm')\");\n+        try {\n+          modelAccess.saveDocument(webHomeDoc, \"createdAndSetContent\");\n+        } catch (DocumentSaveException dse) {\n+          LOGGER.error(\"Exception saving registration space WebHome document.\", dse);\n+        }\n+      }\n+    }\n+  }\n+\n+  void sendConfirmationMail(RegistrationData data) throws XWikiException {\n+    VelocityContext vcontext = (VelocityContext) getContext().get(\"vcontext\");\n+    vcontext.put(\"registrationData\", data);\n+    String htmlContent = new RenderCommand().renderCelementsCell(new DocumentReference(\n+        modelContext.getWikiRef().getName(), \"MailContent\", \"NeueAnmeldung\"));\n+    String textContent = \"-\";\n+    try {\n+      textContent = new PlainTextCommand().convertHtmlToPlainText(htmlContent);\n+    } catch (ConvertToPlainTextException ctpte) {\n+      LOGGER.error(\"could not convert mail html content to plain text\", ctpte);\n+    }\n+    XWikiMessageTool msgTool = webUtilsService.getMessageTool(getContext().getLanguage());\n+    // TODO get correct from / replyTo addresses\n+    // TODO add generic dictionary key to general dictionary\n+    // (event_reg_verification_mail_subject)\n+    mailSender.sendMail(\"reg@bellis.cel.sneakapeek.ch\", \"reg@bellis.cel.sneakapeek.ch\",\n+        data.getMainEmail(), null, null, msgTool.get(\"event_reg_verification_mail_subject\"),\n+        htmlContent, textContent, null, null);\n+  }\n+\n+  @Override\n+  public String normalizeEmail(String emailAdr) {\n+    return emailAdr.toLowerCase().trim();\n+  }\n+\n+  String getClientInfo() {\n+    String clientInfo = new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\").format(new Date());","path":"src/main/java/com/celements/course/service/CourseService.java","position":206,"original_position":206,"commit_id":"0127266e894b22cbc7805bf812f221dfc207706c","original_commit_id":"0127266e894b22cbc7805bf812f221dfc207706c","user":{"login":"fpichler","id":777336,"avatar_url":"https://avatars.githubusercontent.com/u/777336?v=3","gravatar_id":"","url":"https://api.github.com/users/fpichler","html_url":"https://github.com/fpichler","followers_url":"https://api.github.com/users/fpichler/followers","following_url":"https://api.github.com/users/fpichler/following{/other_user}","gists_url":"https://api.github.com/users/fpichler/gists{/gist_id}","starred_url":"https://api.github.com/users/fpichler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpichler/subscriptions","organizations_url":"https://api.github.com/users/fpichler/orgs","repos_url":"https://api.github.com/users/fpichler/repos","events_url":"https://api.github.com/users/fpichler/events{/privacy}","received_events_url":"https://api.github.com/users/fpichler/received_events","type":"User","site_admin":false},"body":"Please use StringBuilder","created_at":"2016-10-04T16:43:15Z","updated_at":"2016-10-04T16:43:15Z","html_url":"https://github.com/celements/celements-course/pull/2#discussion_r81800612","pull_request_url":"https://api.github.com/repos/celements/celements-course/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/celements/celements-course/pulls/comments/81800612"},"html":{"href":"https://github.com/celements/celements-course/pull/2#discussion_r81800612"},"pull_request":{"href":"https://api.github.com/repos/celements/celements-course/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/celements/celements-course/pulls/2","id":87921138,"html_url":"https://github.com/celements/celements-course/pull/2","diff_url":"https://github.com/celements/celements-course/pull/2.diff","patch_url":"https://github.com/celements/celements-course/pull/2.patch","issue_url":"https://api.github.com/repos/celements/celements-course/issues/2","number":2,"state":"open","locked":false,"title":"Feature event registration","user":{"login":"ebeutler","id":777164,"avatar_url":"https://avatars.githubusercontent.com/u/777164?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeutler","html_url":"https://github.com/ebeutler","followers_url":"https://api.github.com/users/ebeutler/followers","following_url":"https://api.github.com/users/ebeutler/following{/other_user}","gists_url":"https://api.github.com/users/ebeutler/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeutler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeutler/subscriptions","organizations_url":"https://api.github.com/users/ebeutler/orgs","repos_url":"https://api.github.com/users/ebeutler/repos","events_url":"https://api.github.com/users/ebeutler/events{/privacy}","received_events_url":"https://api.github.com/users/ebeutler/received_events","type":"User","site_admin":false},"body":"First, basic, implementation for event attendance registration","created_at":"2016-10-04T15:45:29Z","updated_at":"2016-10-04T16:49:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3881ed77ad6620e1a2a369ae09cf45521c090877","assignee":{"login":"fpichler","id":777336,"avatar_url":"https://avatars.githubusercontent.com/u/777336?v=3","gravatar_id":"","url":"https://api.github.com/users/fpichler","html_url":"https://github.com/fpichler","followers_url":"https://api.github.com/users/fpichler/followers","following_url":"https://api.github.com/users/fpichler/following{/other_user}","gists_url":"https://api.github.com/users/fpichler/gists{/gist_id}","starred_url":"https://api.github.com/users/fpichler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpichler/subscriptions","organizations_url":"https://api.github.com/users/fpichler/orgs","repos_url":"https://api.github.com/users/fpichler/repos","events_url":"https://api.github.com/users/fpichler/events{/privacy}","received_events_url":"https://api.github.com/users/fpichler/received_events","type":"User","site_admin":false},"assignees":[{"login":"fpichler","id":777336,"avatar_url":"https://avatars.githubusercontent.com/u/777336?v=3","gravatar_id":"","url":"https://api.github.com/users/fpichler","html_url":"https://github.com/fpichler","followers_url":"https://api.github.com/users/fpichler/followers","following_url":"https://api.github.com/users/fpichler/following{/other_user}","gists_url":"https://api.github.com/users/fpichler/gists{/gist_id}","starred_url":"https://api.github.com/users/fpichler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpichler/subscriptions","organizations_url":"https://api.github.com/users/fpichler/orgs","repos_url":"https://api.github.com/users/fpichler/repos","events_url":"https://api.github.com/users/fpichler/events{/privacy}","received_events_url":"https://api.github.com/users/fpichler/received_events","type":"User","site_admin":false},{"login":"msladek","id":1436305,"avatar_url":"https://avatars.githubusercontent.com/u/1436305?v=3","gravatar_id":"","url":"https://api.github.com/users/msladek","html_url":"https://github.com/msladek","followers_url":"https://api.github.com/users/msladek/followers","following_url":"https://api.github.com/users/msladek/following{/other_user}","gists_url":"https://api.github.com/users/msladek/gists{/gist_id}","starred_url":"https://api.github.com/users/msladek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msladek/subscriptions","organizations_url":"https://api.github.com/users/msladek/orgs","repos_url":"https://api.github.com/users/msladek/repos","events_url":"https://api.github.com/users/msladek/events{/privacy}","received_events_url":"https://api.github.com/users/msladek/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/celements/celements-course/pulls/2/commits","review_comments_url":"https://api.github.com/repos/celements/celements-course/pulls/2/comments","review_comment_url":"https://api.github.com/repos/celements/celements-course/pulls/comments{/number}","comments_url":"https://api.github.com/repos/celements/celements-course/issues/2/comments","statuses_url":"https://api.github.com/repos/celements/celements-course/statuses/0127266e894b22cbc7805bf812f221dfc207706c","head":{"label":"celements:feature_eventRegistration","ref":"feature_eventRegistration","sha":"0127266e894b22cbc7805bf812f221dfc207706c","user":{"login":"celements","id":866913,"avatar_url":"https://avatars.githubusercontent.com/u/866913?v=3","gravatar_id":"","url":"https://api.github.com/users/celements","html_url":"https://github.com/celements","followers_url":"https://api.github.com/users/celements/followers","following_url":"https://api.github.com/users/celements/following{/other_user}","gists_url":"https://api.github.com/users/celements/gists{/gist_id}","starred_url":"https://api.github.com/users/celements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/celements/subscriptions","organizations_url":"https://api.github.com/users/celements/orgs","repos_url":"https://api.github.com/users/celements/repos","events_url":"https://api.github.com/users/celements/events{/privacy}","received_events_url":"https://api.github.com/users/celements/received_events","type":"Organization","site_admin":false},"repo":{"id":2747975,"name":"celements-course","full_name":"celements/celements-course","owner":{"login":"celements","id":866913,"avatar_url":"https://avatars.githubusercontent.com/u/866913?v=3","gravatar_id":"","url":"https://api.github.com/users/celements","html_url":"https://github.com/celements","followers_url":"https://api.github.com/users/celements/followers","following_url":"https://api.github.com/users/celements/following{/other_user}","gists_url":"https://api.github.com/users/celements/gists{/gist_id}","starred_url":"https://api.github.com/users/celements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/celements/subscriptions","organizations_url":"https://api.github.com/users/celements/orgs","repos_url":"https://api.github.com/users/celements/repos","events_url":"https://api.github.com/users/celements/events{/privacy}","received_events_url":"https://api.github.com/users/celements/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/celements/celements-course","description":"Administration of courses ","fork":false,"url":"https://api.github.com/repos/celements/celements-course","forks_url":"https://api.github.com/repos/celements/celements-course/forks","keys_url":"https://api.github.com/repos/celements/celements-course/keys{/key_id}","collaborators_url":"https://api.github.com/repos/celements/celements-course/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/celements/celements-course/teams","hooks_url":"https://api.github.com/repos/celements/celements-course/hooks","issue_events_url":"https://api.github.com/repos/celements/celements-course/issues/events{/number}","events_url":"https://api.github.com/repos/celements/celements-course/events","assignees_url":"https://api.github.com/repos/celements/celements-course/assignees{/user}","branches_url":"https://api.github.com/repos/celements/celements-course/branches{/branch}","tags_url":"https://api.github.com/repos/celements/celements-course/tags","blobs_url":"https://api.github.com/repos/celements/celements-course/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/celements/celements-course/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/celements/celements-course/git/refs{/sha}","trees_url":"https://api.github.com/repos/celements/celements-course/git/trees{/sha}","statuses_url":"https://api.github.com/repos/celements/celements-course/statuses/{sha}","languages_url":"https://api.github.com/repos/celements/celements-course/languages","stargazers_url":"https://api.github.com/repos/celements/celements-course/stargazers","contributors_url":"https://api.github.com/repos/celements/celements-course/contributors","subscribers_url":"https://api.github.com/repos/celements/celements-course/subscribers","subscription_url":"https://api.github.com/repos/celements/celements-course/subscription","commits_url":"https://api.github.com/repos/celements/celements-course/commits{/sha}","git_commits_url":"https://api.github.com/repos/celements/celements-course/git/commits{/sha}","comments_url":"https://api.github.com/repos/celements/celements-course/comments{/number}","issue_comment_url":"https://api.github.com/repos/celements/celements-course/issues/comments{/number}","contents_url":"https://api.github.com/repos/celements/celements-course/contents/{+path}","compare_url":"https://api.github.com/repos/celements/celements-course/compare/{base}...{head}","merges_url":"https://api.github.com/repos/celements/celements-course/merges","archive_url":"https://api.github.com/repos/celements/celements-course/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/celements/celements-course/downloads","issues_url":"https://api.github.com/repos/celements/celements-course/issues{/number}","pulls_url":"https://api.github.com/repos/celements/celements-course/pulls{/number}","milestones_url":"https://api.github.com/repos/celements/celements-course/milestones{/number}","notifications_url":"https://api.github.com/repos/celements/celements-course/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/celements/celements-course/labels{/name}","releases_url":"https://api.github.com/repos/celements/celements-course/releases{/id}","deployments_url":"https://api.github.com/repos/celements/celements-course/deployments","created_at":"2011-11-10T10:58:13Z","updated_at":"2016-08-25T15:57:12Z","pushed_at":"2016-10-04T15:45:30Z","git_url":"git://github.com/celements/celements-course.git","ssh_url":"git@github.com:celements/celements-course.git","clone_url":"https://github.com/celements/celements-course.git","svn_url":"https://github.com/celements/celements-course","homepage":"","size":95,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"dev"}},"base":{"label":"celements:dev","ref":"dev","sha":"cfe02f3bf25962275e301a0ae98e73dc481e4631","user":{"login":"celements","id":866913,"avatar_url":"https://avatars.githubusercontent.com/u/866913?v=3","gravatar_id":"","url":"https://api.github.com/users/celements","html_url":"https://github.com/celements","followers_url":"https://api.github.com/users/celements/followers","following_url":"https://api.github.com/users/celements/following{/other_user}","gists_url":"https://api.github.com/users/celements/gists{/gist_id}","starred_url":"https://api.github.com/users/celements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/celements/subscriptions","organizations_url":"https://api.github.com/users/celements/orgs","repos_url":"https://api.github.com/users/celements/repos","events_url":"https://api.github.com/users/celements/events{/privacy}","received_events_url":"https://api.github.com/users/celements/received_events","type":"Organization","site_admin":false},"repo":{"id":2747975,"name":"celements-course","full_name":"celements/celements-course","owner":{"login":"celements","id":866913,"avatar_url":"https://avatars.githubusercontent.com/u/866913?v=3","gravatar_id":"","url":"https://api.github.com/users/celements","html_url":"https://github.com/celements","followers_url":"https://api.github.com/users/celements/followers","following_url":"https://api.github.com/users/celements/following{/other_user}","gists_url":"https://api.github.com/users/celements/gists{/gist_id}","starred_url":"https://api.github.com/users/celements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/celements/subscriptions","organizations_url":"https://api.github.com/users/celements/orgs","repos_url":"https://api.github.com/users/celements/repos","events_url":"https://api.github.com/users/celements/events{/privacy}","received_events_url":"https://api.github.com/users/celements/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/celements/celements-course","description":"Administration of courses ","fork":false,"url":"https://api.github.com/repos/celements/celements-course","forks_url":"https://api.github.com/repos/celements/celements-course/forks","keys_url":"https://api.github.com/repos/celements/celements-course/keys{/key_id}","collaborators_url":"https://api.github.com/repos/celements/celements-course/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/celements/celements-course/teams","hooks_url":"https://api.github.com/repos/celements/celements-course/hooks","issue_events_url":"https://api.github.com/repos/celements/celements-course/issues/events{/number}","events_url":"https://api.github.com/repos/celements/celements-course/events","assignees_url":"https://api.github.com/repos/celements/celements-course/assignees{/user}","branches_url":"https://api.github.com/repos/celements/celements-course/branches{/branch}","tags_url":"https://api.github.com/repos/celements/celements-course/tags","blobs_url":"https://api.github.com/repos/celements/celements-course/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/celements/celements-course/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/celements/celements-course/git/refs{/sha}","trees_url":"https://api.github.com/repos/celements/celements-course/git/trees{/sha}","statuses_url":"https://api.github.com/repos/celements/celements-course/statuses/{sha}","languages_url":"https://api.github.com/repos/celements/celements-course/languages","stargazers_url":"https://api.github.com/repos/celements/celements-course/stargazers","contributors_url":"https://api.github.com/repos/celements/celements-course/contributors","subscribers_url":"https://api.github.com/repos/celements/celements-course/subscribers","subscription_url":"https://api.github.com/repos/celements/celements-course/subscription","commits_url":"https://api.github.com/repos/celements/celements-course/commits{/sha}","git_commits_url":"https://api.github.com/repos/celements/celements-course/git/commits{/sha}","comments_url":"https://api.github.com/repos/celements/celements-course/comments{/number}","issue_comment_url":"https://api.github.com/repos/celements/celements-course/issues/comments{/number}","contents_url":"https://api.github.com/repos/celements/celements-course/contents/{+path}","compare_url":"https://api.github.com/repos/celements/celements-course/compare/{base}...{head}","merges_url":"https://api.github.com/repos/celements/celements-course/merges","archive_url":"https://api.github.com/repos/celements/celements-course/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/celements/celements-course/downloads","issues_url":"https://api.github.com/repos/celements/celements-course/issues{/number}","pulls_url":"https://api.github.com/repos/celements/celements-course/pulls{/number}","milestones_url":"https://api.github.com/repos/celements/celements-course/milestones{/number}","notifications_url":"https://api.github.com/repos/celements/celements-course/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/celements/celements-course/labels{/name}","releases_url":"https://api.github.com/repos/celements/celements-course/releases{/id}","deployments_url":"https://api.github.com/repos/celements/celements-course/deployments","created_at":"2011-11-10T10:58:13Z","updated_at":"2016-08-25T15:57:12Z","pushed_at":"2016-10-04T15:45:30Z","git_url":"git://github.com/celements/celements-course.git","ssh_url":"git@github.com:celements/celements-course.git","clone_url":"https://github.com/celements/celements-course.git","svn_url":"https://github.com/celements/celements-course","homepage":"","size":95,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/celements/celements-course/pulls/2"},"html":{"href":"https://github.com/celements/celements-course/pull/2"},"issue":{"href":"https://api.github.com/repos/celements/celements-course/issues/2"},"comments":{"href":"https://api.github.com/repos/celements/celements-course/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/celements/celements-course/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/celements/celements-course/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/celements/celements-course/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/celements/celements-course/statuses/0127266e894b22cbc7805bf812f221dfc207706c"}}}}
{"actor":{"display_login":"fpichler"}}