Code Duplication    Length = 7-9 lines in 7 locations

apps/files_external/controller/storagescontroller.php 2 locations

@@ 205-213 (lines=9) @@
202
			);
203
		}
204
205
		if (!$backend->validateStorage($storage)) {
206
			// unsatisfied parameters
207
			return new DataResponse(
208
				array(
209
					'message' => (string)$this->l10n->t('Unsatisfied backend parameters')
210
				),
211
				Http::STATUS_UNPROCESSABLE_ENTITY
212
			);
213
		}
214
		if (!$authMechanism->validateStorage($storage)) {
215
			// unsatisfied parameters
216
			return new DataResponse(
@@ 214-222 (lines=9) @@
211
				Http::STATUS_UNPROCESSABLE_ENTITY
212
			);
213
		}
214
		if (!$authMechanism->validateStorage($storage)) {
215
			// unsatisfied parameters
216
			return new DataResponse(
217
				[
218
					'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters')
219
				],
220
				Http::STATUS_UNPROCESSABLE_ENTITY
221
			);
222
		}
223
224
		return null;
225
	}

core/controller/avatarcontroller.php 3 locations

@@ 191-197 (lines=7) @@
188
				$this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200);
189
				$content = $this->cache->get('avatar_upload');
190
				unlink($files['tmp_name'][0]);
191
			} else {
192
				return new DataResponse(
193
					['data' => ['message' => $this->l->t('Invalid file provided')]],
194
					Http::STATUS_BAD_REQUEST,
195
					$headers
196
				);
197
			}
198
		} else {
199
			//Add imgfile
200
			return new DataResponse(
@@ 198-205 (lines=8) @@
195
					$headers
196
				);
197
			}
198
		} else {
199
			//Add imgfile
200
			return new DataResponse(
201
				['data' => ['message' => $this->l->t('No image or file provided')]],
202
				Http::STATUS_BAD_REQUEST,
203
				$headers
204
			);
205
		}
206
207
		try {
208
			$image = new \OC_Image();
@@ 228-234 (lines=7) @@
225
					Http::STATUS_OK,
226
					$headers
227
				);
228
			} else {
229
				return new DataResponse(
230
					['data' => ['message' => $this->l->t('Invalid image')]],
231
					Http::STATUS_OK,
232
					$headers
233
				);
234
			}
235
		} catch (\Exception $e) {
236
			$this->logger->logException($e, ['app' => 'core']);
237
			return new DataResponse(['data' => ['message' => $this->l->t('An error occurred. Please contact your admin.')]], Http::STATUS_OK, $headers);

apps/files_external/controller/userglobalstoragescontroller.php 1 location

@@ 159-166 (lines=8) @@
156
			if ($authMechanism instanceof IUserProvided) {
157
				$authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions);
158
				$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
159
			} else {
160
				return new DataResponse(
161
					[
162
						'message' => (string)$this->l10n->t('Storage with id "%i" is not user editable', array($id))
163
					],
164
					Http::STATUS_FORBIDDEN
165
				);
166
			}
167
		} catch (NotFoundException $e) {
168
			return new DataResponse(
169
				[

apps/theming/lib/controller/themingcontroller.php 1 location

@@ 104-112 (lines=9) @@
101
	public function updateLogo() {
102
		$newLogo = $this->request->getUploadedFile('uploadlogo');
103
		$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
104
		if (empty($newLogo) && empty($newBackgroundLogo)) {
105
			return new DataResponse(
106
				[
107
					'data' => [
108
						'message' => $this->l->t('No file uploaded')
109
					]
110
				],
111
				Http::STATUS_UNPROCESSABLE_ENTITY);
112
		}
113
		$name = '';
114
		if(!empty($newLogo)) {
115
			$target = $this->rootFolder->newFile('themedinstancelogo');