58 $groupId = $this->restHelper->getGroupId();
59 $dbManager = $this->dbHelper->getDbManager();
61 $uploadBrowseProxy->sanity();
75 if (isset($args[
'id'])) {
76 $id = intval($args[
'id']);
78 if ($upload !==
true) {
79 return $response->withJson($upload->getArray(), $upload->getCode());
86 $uploads = $this->dbHelper->getUploads($this->restHelper->getUserId(), $id);
88 $uploads = $uploads[0];
90 return $response->withJson($uploads, 200);
103 $id = intval($args[
'id']);
105 if ($upload !==
true) {
106 return $response->withJson($upload->getArray(), $upload->getCode());
109 if ($temp !==
true) {
113 $uploadSummary = $uploadHelper->generateUploadSummary($id,
114 $this->restHelper->getGroupId());
115 return $response->withJson($uploadSummary->getArray(), 200);
128 require_once dirname(dirname(dirname(dirname(__DIR__)))) .
129 "/delagent/ui/delete-helper.php";
131 $id = intval($args[
'id']);
134 if ($upload !==
true) {
135 return $response->withJson($upload->getArray(), $upload->getCode());
137 $result = TryToDelete($id, $this->restHelper->getUserId(),
138 $this->restHelper->getGroupId(), $this->restHelper->getUploadDao());
140 $returnVal =
new Info(500, $result->getDeleteMessageString(),
143 $returnVal =
new Info(202,
"Delete Job for file with id " . $id,
146 return $response->withJson($returnVal->getArray(), $returnVal->getCode());
159 return $this->
changeUpload($request, $response, $args,
true);
172 return $this->
changeUpload($request, $response, $args,
false);
187 if ($request->hasHeader(
'folderId') &&
188 is_numeric($newFolderID = $request->getHeaderLine(
'folderId'))) {
189 $id = intval($args[
'id']);
190 $returnVal = $this->restHelper->copyUpload($id, $newFolderID, $isCopy);
192 $returnVal =
new Info(400,
"folderId header should be an integer!",
195 return $response->withJson($returnVal->getArray(), $returnVal->getCode());
209 if ($request->hasHeader(
'folderId') &&
210 is_numeric($folderId = $request->getHeaderLine(
'folderId')) && $folderId > 0) {
212 $allFolderIds = $this->restHelper->getFolderDao()->getAllFolderIds();
213 if (!in_array($folderId, $allFolderIds)) {
214 $error =
new Info(404,
"folderId $folderId does not exists!", InfoType::ERROR);
215 return $response->withJson($error->getArray(), $error->getCode());
217 if (!$this->restHelper->getFolderDao()->isFolderAccessible($folderId)) {
218 $error =
new Info(403,
"folderId $folderId is not accessible!",
220 return $response->withJson($error->getArray(), $error->getCode());
223 $description = $request->getHeaderLine(
'uploadDescription');
224 $public = $request->getHeaderLine(
'public');
225 $public = empty($public) ?
'protected' : $public;
226 $ignoreScm = $request->getHeaderLine(
'ignoreScm');
227 $uploadType = $request->getHeaderLine(
'uploadType');
228 if (empty($uploadType)) {
231 $uploadResponse = $uploadHelper->createNewUpload($request, $folderId,
232 $description, $public, $ignoreScm, $uploadType);
233 $status = $uploadResponse[0];
234 $message = $uploadResponse[1];
235 $statusDescription = $uploadResponse[2];
237 $info =
new Info(500, $message .
"\n" . $statusDescription,
240 $uploadId = $uploadResponse[3];
241 $info =
new Info(201, intval($uploadId), InfoType::INFO);
243 return $response->withJson($info->getArray(), $info->getCode());
245 $error =
new Info(400,
"folderId must be a positive integer!",
247 return $response->withJson($error->getArray(), $error->getCode());
261 $id = intval($args[
'id']);
262 $query = $request->getQueryParams();
264 if (! array_key_exists(self::AGENT_PARAM, $query)) {
265 $error =
new Info(400,
"'agent' parameter missing from query.",
267 return $response->withJson($error->getArray(), $error->getCode());
269 $agents = explode(
",", $query[self::AGENT_PARAM]);
271 if (array_key_exists(self::CONTAINER_PARAM, $query)) {
272 $containers = (strcasecmp($query[self::CONTAINER_PARAM],
"true") === 0);
276 if ($upload !==
true) {
277 return $response->withJson($upload->getArray(), $upload->getCode());
281 if ($adj2nest !==
true) {
283 }
else if ($agentScheduled !==
true) {
284 return $agentScheduled;
288 $licenseList = $uploadHelper->getUploadLicenseList($id, $agents,
290 return $response->withJson($licenseList, 200);
302 if (! $this->dbHelper->doesIdExist(
"upload",
"upload_pk", $id)) {
303 return new Info(404,
"Upload does not exist", InfoType::ERROR);
304 }
else if (! $this->restHelper->getUploadDao()->isAccessible($id, $groupId)) {
305 return new Info(403,
"Upload is not accessible", InfoType::ERROR);
318 $itemTreeBounds = $this->restHelper->getUploadDao()->getParentItemBounds(
320 if ($itemTreeBounds ===
false || empty($itemTreeBounds->getLeft())) {
321 $returnVal =
new Info(503,
322 "Ununpack job not started. Please check job status at " .
323 "/api/v1/jobs?upload=" . $id, InfoType::INFO);
324 return $response->withHeader(
'Retry-After',
'60')
325 ->withHeader(
'Look-at',
"/api/v1/jobs?upload=" . $id)
326 ->withJson($returnVal->getArray(), $returnVal->getCode());
342 $agentDao = $container->get(
'dao.agent');
344 $agentList = array_keys(AgentRef::AGENT_LIST);
345 $intersectArray = array_intersect($agents, $agentList);
348 if (count($agents) != count($intersectArray)) {
349 $error =
new Info(400,
"Agent should be any of " .
350 implode(
", ", $agentList) .
". " . implode(
",", $agents) .
" passed.",
354 foreach ($agents as $agent) {
355 if (! $agentDao->arsTableExists($agent)) {
356 $error =
new Info(412,
"Agent $agent not scheduled for the upload. " .
357 "Please POST to /jobs", InfoType::ERROR);
362 if ($error !== null) {
363 return $response->withJson($error->getArray(), $error->getCode());
367 $agentList = $scanProx->createAgentStatus($agents);
369 foreach ($agentList as $agent) {
370 if (! array_key_exists(
'currentAgentId', $agent)) {
371 $error =
new Info(412,
"Agent " . $agent[
"agentName"] .
372 " not scheduled for the upload. Please POST to /jobs",
374 $response = $response->withJson($error->getArray(), $error->getCode());
375 }
else if ($agent[
'isAgentRunning']) {
376 $error =
new Info(503,
"Agent $agent is running. " .
377 "Please check job status at /api/v1/jobs?upload=" . $uploadId,
379 $response = $response->withHeader(
'Retry-After',
'60')
380 ->withHeader(
'Look-at',
"/api/v1/jobs?upload=" . $uploadId)
381 ->withJson($error->getArray(), $error->getCode());
383 if ($error !== null) {
changeUpload($request, $response, $args, $isCopy)
getUploadSummary($request, $response, $args)
Base controller for REST calls.
deleteUpload($request, $response, $args)
Controller for Upload model.
moveUpload($request, $response, $args)
isAdj2nestDone($id, $response)
uploadAccessible($groupId, $id)
postUpload($request, $response, $args)
Handle new file uploads from Slim framework and move to FOSSology.
areAgentsScheduled($uploadId, $agents, $response)
copyUpload($request, $response, $args)
getUploads($request, $response, $args)
Info model to contain general error and return values.
getUploadLicenses($request, $response, $args)