/**
  * @Route(
  *      "/{resourceId}/open/resource/{documentId}",
  *      name="icap_dropzone_open_resource",
  *      requirements={"resourceId" = "\d+", "documentId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("document", class="IcapDropzoneBundle:Document", options={"id" = "documentId"})
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @Template()
  */
 public function openResourceAction(Dropzone $dropzone, Document $document, $user)
 {
     $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone);
     if ($document->getType() == 'url') {
         return $this->redirect($document->getUrl());
     } elseif ($document->getType() == 'text' or $document->getType() == 'resource' or $document->getType() == 'file') {
         $this->get('claroline.temporary_access_resource_manager')->addTemporaryAccess($document->getResourceNode(), $user);
         $event = new LogDocumentOpenEvent($dropzone, $document->getDrop(), $document);
         $this->dispatch($event);
         if ($document->getResourceNode()->getResourceType()->getName() == 'file') {
             return $this->redirect($this->generateUrl('claro_resource_download') . '?ids[]=' . $document->getResourceNode()->getId());
         } else {
             return $this->redirect($this->generateUrl('claro_resource_open', array('resourceType' => $document->getResourceNode()->getResourceType()->getName(), 'node' => $document->getResourceNode()->getId())));
         }
     }
 }