Beispiel #1
0
  @Override
  public ModelAndView generateFeed(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    RequestContext requestContext = RequestContext.getRequestContext();
    Path uri = requestContext.getResourceURI();
    String token = requestContext.getSecurityToken();
    Resource feedScope = requestContext.getRepository().retrieve(token, uri, true);

    Map<String, Object> feedContent = new HashMap<String, Object>();

    // Title, link and description are required by spec
    feedContent.put("title", getTitle(feedScope, requestContext));
    feedContent.put("link", request.getRequestURL().toString());
    Property introductionProp = feedScope.getProperty(introductionPropDef);
    String description =
        introductionProp != null
            ? introductionProp.getFormattedValue(HtmlValueFormatter.FLATTENED_FORMAT, null)
            : "";
    feedContent.put("description", description);

    // Optional elements
    feedContent.put("atomLink", requestContext.getRequestURL().toString());

    if (!StringUtils.isBlank(feedLogoPath)) {
      feedContent.put("feedLogoPath", feedLogoPath);
    }

    feedContent.put("feedItems", getFeedEntries(feedScope));

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("feedContent", feedContent);

    return new ModelAndView(viewName, model);
  }
 public void removePropertyValue(PropertyTypeDefinition propDef) throws Exception {
   RequestContext requestContext = RequestContext.getRequestContext();
   Repository repository = requestContext.getRepository();
   String token = SecurityContext.getSecurityContext().getToken();
   Path uri = requestContext.getResourceURI();
   Resource resource = repository.retrieve(token, uri, true);
   if (resource.getProperty(propDef) != null) {
     resource.removeProperty(propDef);
     repository.store(token, resource);
   }
 }
 public void setPropertyDateValue(PropertyTypeDefinition datePropDef, Date date) throws Exception {
   RequestContext requestContext = RequestContext.getRequestContext();
   Repository repository = requestContext.getRepository();
   String token = SecurityContext.getSecurityContext().getToken();
   Path uri = requestContext.getResourceURI();
   Resource resource = repository.retrieve(token, uri, true);
   Property dateProp = resource.getProperty(datePropDef);
   if (dateProp == null) {
     dateProp = datePropDef.createProperty();
     resource.addProperty(dateProp);
   }
   dateProp.setDateValue(date);
   repository.store(token, resource);
 }
Beispiel #4
0
  private void addPosterUrl(Resource mediaResource, Map<String, Object> model) {
    if (mediaResource == null) return;
    URL poster = null;
    Property posterImageProp = mediaResource.getProperty(posterImagePropDef);
    Property thumbnail = mediaResource.getProperty(thumbnailPropDef);
    if (posterImageProp != null) {
      poster = createUrl(posterImageProp.getStringValue());
    } else if (thumbnail != null) {
      poster = thumbnailService.constructURL(mediaResource);
      // Work-around for SelectiveProtocolManager URL post-processing which sets
      // URL protocol to "http" for open resources, but this causes mixed-mode
      // in secure page context, since this URL points to an inline element (image).
      if (RequestContext.exists()) {
        if (RequestContext.getRequestContext().getServletRequest().isSecure()) {
          poster.setProtocol("https");
        }
      }
    }

    if (poster != null) {
      model.put("poster", poster);
    }
  }