+ $this->verifyUser(
+ $username,
+ $this->deps->urlGen->getAbsoluteURL(
+ $this->deps->urlGen->linkToRoute(
+ 'grauphel.api.note',
+ array('username' => $username, 'guid' => $guid)
+ )
+ )
+ );
+
+ $note = $this->notes->load($guid, false);
+ if ($note === null) {
+ header('HTTP/1.0 404 Not Found');
+ header('Content-type: text/plain');
+ echo "Note does not exist\n";
+ exit(1);
+ }
+
+ return new JSONResponse($note);
+ }
+
+ /**
+ * Checks if the given user is authorized (by oauth token or normal login)
+ *
+ * @param string $username Username to verify
+ *
+ * @return boolean True if all is fine, Response in case of an error
+ */
+ protected function verifyUser($username, $curUrl)
+ {
+ if ($this->user !== null && $this->user->getUid() == $username) {
+ $this->notes->setUsername($username);
+ return true;
+ }