Code Duplication    Length = 20-20 lines in 3 locations

apps/testing/locking/provisioning.php 3 locations

@@ 107-126 (lines=20) @@
104
	 * @param array $parameters
105
	 * @return \OC_OCS_Result
106
	 */
107
	public function acquireLock(array $parameters) {
108
		try {
109
			$path = $this->getPath($parameters);
110
		} catch (NoUserException $e) {
111
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
112
		} catch (NotFoundException $e) {
113
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
114
		}
115
		$type = $this->getType($parameters);
116
117
		$lockingProvider = $this->getLockingProvider();
118
119
		try {
120
			$lockingProvider->acquireLock($path, $type);
121
			$this->config->setAppValue('testing', 'locking_' . $path, $type);
122
			return new \OC_OCS_Result(null, 100);
123
		} catch (LockedException $e) {
124
			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
125
		}
126
	}
127
128
	/**
129
	 * @param array $parameters
@@ 132-151 (lines=20) @@
129
	 * @param array $parameters
130
	 * @return \OC_OCS_Result
131
	 */
132
	public function changeLock(array $parameters) {
133
		try {
134
			$path = $this->getPath($parameters);
135
		} catch (NoUserException $e) {
136
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
137
		} catch (NotFoundException $e) {
138
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
139
		}
140
		$type = $this->getType($parameters);
141
142
		$lockingProvider = $this->getLockingProvider();
143
144
		try {
145
			$lockingProvider->changeLock($path, $type);
146
			$this->config->setAppValue('testing', 'locking_' . $path, $type);
147
			return new \OC_OCS_Result(null, 100);
148
		} catch (LockedException $e) {
149
			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
150
		}
151
	}
152
153
	/**
154
	 * @param array $parameters
@@ 157-176 (lines=20) @@
154
	 * @param array $parameters
155
	 * @return \OC_OCS_Result
156
	 */
157
	public function releaseLock(array $parameters) {
158
		try {
159
			$path = $this->getPath($parameters);
160
		} catch (NoUserException $e) {
161
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
162
		} catch (NotFoundException $e) {
163
			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
164
		}
165
		$type = $this->getType($parameters);
166
167
		$lockingProvider = $this->getLockingProvider();
168
169
		try {
170
			$lockingProvider->releaseLock($path, $type);
171
			$this->config->deleteAppValue('testing', 'locking_' . $path);
172
			return new \OC_OCS_Result(null, 100);
173
		} catch (LockedException $e) {
174
			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
175
		}
176
	}
177
178
	/**
179
	 * @param array $parameters