Code Duplication    Length = 15-21 lines in 2 locations

lib/Service/OwnNoteService.php 2 locations

@@ 74-88 (lines=15) @@
71
	 * @return OwnNote
72
	 * @throws \Exception
73
	 */
74
	public function create($note, $userId) {
75
		if (is_array($note)) {
76
			$entity = new OwnNote();
77
			$entity->setName($note['title']);
78
			$entity->setUid($userId);
79
			$entity->setGrouping($note['group']);
80
			$entity->setNote($note['note'] ? $note['note'] : '');
81
			$entity->setMtime(time());
82
			$note = $entity;
83
		}
84
		if (!$note instanceof OwnNote) {
85
			throw new \Exception("Expected OwnNote object!");
86
		}
87
		return $this->noteMapper->create($note);
88
	}
89
90
	/**
91
	 * Update vault
@@ 99-119 (lines=21) @@
96
	 * @internal param $userId
97
	 * @internal param $vault
98
	 */
99
	public function update($note) {
100
101
		if (is_array($note)) {
102
			$entity = $this->find($note['id']);
103
			$entity->setName($note['name']);
104
			$entity->setGrouping($note['group']);
105
			$entity->setNote($note['note']);
106
			$entity->setMtime(time());
107
			$note = $entity;
108
		}
109
		if (!$note instanceof OwnNote) {
110
			throw new \Exception("Expected OwnNote object!");
111
		}
112
113
		// @TODO check if we can enable this without issues
114
//		if (!$this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE, $note->getId())) {
115
//			return false;
116
//		}
117
118
		return $this->noteMapper->updateNote($note);
119
	}
120
121
	public function renameNote($FOLDER, $id, $in_newname, $in_newgroup, $uid = null) {
122
		$newname = str_replace("\\", "-", str_replace("/", "-", $in_newname));