123 $session = $this->authHelper->getSession();
132 $session = $this->authHelper->getSession();
209 if (is_numeric($newFolderId) && $newFolderId > 0) {
210 if (!$this->folderDao->isFolderAccessible($newFolderId, $this->getUserId())) {
211 return new Info(403,
"Folder is not accessible.",
214 if (!$this->uploadPermissionDao->isAccessible($uploadId, $this->getGroupId())) {
215 return new Info(403,
"Upload is not accessible.",
218 $uploadContentId = $this->folderDao->getFolderContentsId($uploadId);
219 $contentMove = $this->
getPlugin(
'content_move');
221 $errors = $contentMove->copyContent([$uploadContentId], $newFolderId, $isCopy);
222 if (empty($errors)) {
223 $action = $isCopy ?
"copied" :
"moved";
224 $info =
new Info(202,
"Upload $uploadId will be $action to folder $newFolderId",
227 $info =
new Info(202,
"Exceptions occurred: $errors",
232 return new Info(400,
"Bad Request. Folder id should be a positive integer",
252 throw new \UnexpectedValueException(
253 "Unable to find plugin " . $pluginName);
275 $requestValid =
true;
276 $tokenValidity = $this->authHelper->getMaxTokenValidity();
278 if (strtotime($tokenExpire) < strtotime(
"tomorrow") ||
279 ! preg_match(
"/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",
281 strtotime($tokenExpire) > strtotime(
"+$tokenValidity days")) {
282 $requestValid =
new Info(400,
283 "The token should have at least 1 day and max $tokenValidity days " .
284 "of validity and should follow YYYY-MM-DD format.", InfoType::ERROR);
286 $requestValid =
new Info(400,
287 "Invalid token scope, allowed only " .
289 } elseif (empty($tokenName) || strlen($tokenName) > 40) {
290 $requestValid =
new Info(400,
291 "The token name must be a valid string of max 40 character length",
294 return $requestValid;
__construct(UploadPermissionDao $uploadPermissionDao, UploadDao $uploadDao, UserDao $userDao, FolderDao $folderDao, DbHelper $dbHelper, AuthHelper $authHelper, JobDao $jobDao, ShowJobsDao $showJobDao)
RestHelper constructor.
getPlugin($pluginName)
A safe wrapper around plugin_find.
Provides various DAO helper functions for REST api.
Provides helper methods for REST api.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
Info model to contain general error and return values.
Provides helper methods to access database for REST api.
copyUpload($uploadId, $newFolderId, $isCopy)
validateTokenRequest($tokenExpire, $tokenName, $tokenScope)
Check if the token request contains valid parameters.