/**
  * Create and update a SecureContainer path
  * 
  * @param string $guid The ID of the path to upgrade - or null for a new one
  * 
  * @return JSONResponse
  * 
  * @NoAdminRequired
  */
 public function section($guid)
 {
     try {
         // Check for a valid post data format
         $data = (object) $this->request->post;
         if (!is_object($data) || !isset($data->name)) {
             throw new \Exception('Invalid data posted for create a new path in SecureContainer.');
         }
         // Create the response
         $response = $this->getResponseSkeleton('section');
         // Create or Update the entity.
         if ($this->pathMapper->exists($guid)) {
             $entity = $this->pathMapper->find($guid);
             if (isset($data->name)) {
                 $entity->setName($data->name);
             }
             if (isset($data->parentId)) {
                 $data->parentId = intval($data->parentId);
                 $entity->setParent($data->parentId < 0 ? 0 : $data->parentId);
             }
             $this->pathMapper->update($entity);
             $this->appendNavigationEvent('update', array($entity), $response);
         } else {
             $data->parentId = intval($data->parentId);
             $entity = new Path();
             $entity->setUid($this->userId);
             $entity->setName($data->name);
             $entity->setParent($data->parentId < 0 ? 0 : $data->parentId);
             $entity = $this->pathMapper->insert($entity);
             $this->appendNavigationEvent('insert', array($entity), $response);
         }
     } catch (\Exception $ex) {
         return $this->createResponseException($ex, 'section', Http::STATUS_INTERNAL_SERVER_ERROR);
     }
     return new JSONResponse($response);
 }