private function validateArtifactIdsAreInUnassignedTopBacklog($ids, $user, $project) { try { $this->milestone_validator->validateArtifactIdsAreInUnassignedTopBacklog($ids, $user, $project); } catch (ArtifactIsNotInUnassignedTopBacklogItemsException $exception) { throw new RestException(409, $exception->getMessage()); } catch (IdsFromBodyAreNotUniqueException $exception) { throw new RestException(409, $exception->getMessage()); } catch (\Exception $exception) { throw new RestException(400, $exception->getMessage()); } }
/** * Add an item to the backlog of a milestone * * Add an item to the backlog of a milestone * * The item must be of the allowed types (defined in the planning configuration). * The body of the request should be of the form : * { * "artifact" : { * "id" : 458 * } * } * * @url POST {id}/backlog * * @param int $id Id of the milestone * @param BacklogItemReference $item Reference of the Backlog Item {@from body} {@type BacklogItemReference} * * @throw 400 * @throw 403 * @throw 404 */ protected function postBacklog($id, BacklogItemReference $item) { $user = $this->getCurrentUser(); $milestone = $this->getMilestoneById($user, $id); $this->checkIfUserCanChangePrioritiesInMilestone($milestone, $user); $item_id = $item->getArtifactId(); $artifact = $this->getBacklogItemAsArtifact($user, $item_id); $allowed_trackers = $this->backlog_strategy_factory->getBacklogStrategy($milestone)->getDescendantTrackers(); if (!$this->milestone_validator->canBacklogItemBeAddedToMilestone($artifact, $allowed_trackers)) { throw new RestException(400, "Item of type '" . $artifact->getTracker()->getName() . "' cannot be added."); } try { $this->milestone_content_updater->appendElementToMilestoneBacklog($item_id, $user, $milestone); } catch (Tracker_NoChangeException $e) { } $this->sendAllowHeaderForBacklog(); }
/** * @throws IdsFromBodyAreNotUniqueException * @throws ArtifactDoesNotExistException * @throws ArtifactIsNotInBacklogTrackerException * @throws ArtifactIsClosedOrAlreadyPlannedInAnotherMilestone */ public function validate(array $to_add) { $this->milestone_validator->validateArtifactsFromBodyContentWithClosedItems($to_add, $this->milestone, $this->user); }
public function itDoesntAddAnElementAlreadyInContent() { $this->assertEqual($this->milestone_resource_validator->getValidatedArtifactsIdsToAddOrRemoveFromContent($this->user, $this->milestone, null, array(113)), array(112, 113, 114, 115)); }