コード例 #1
0
 /**
  * Computes the URL of the video to display from the identifier of the attached video file and by
  * taking into account the displaying context.
  *
  * @param attachmentId the identifier of the attached video file.
  * @param pageContext the displaying page context.
  * @return the URL of the video file as String.
  */
 private String computeVideoURL(final String attachmentId, final PagesContext pageContext) {
   String videoURL = "";
   if (StringUtil.isDefined(attachmentId)) {
     if (attachmentId.startsWith("/")) {
       videoURL = attachmentId;
     } else {
       AttachmentDetail attachment =
           AttachmentController.searchAttachmentByPK(
               new AttachmentPK(attachmentId, pageContext.getComponentId()));
       if (attachment != null) {
         String webContext = FileServerUtils.getApplicationContext();
         videoURL = webContext + attachment.getAttachmentURL();
       }
     }
   }
   return videoURL;
 }