Esempio n. 1
0
  public String getViewFor(Action mainTabAction) {
    if (!mainTabAction.getId().equals(WebActions.DOCUMENTS_MAIN_TAB_ID)) {
      return mainTabAction.getLink();
    }

    DocumentModel doc =
        getDocumentFor(mainTabAction.getId(), navigationContext.getCurrentDocument());
    if (doc != null) {
      TypeInfo typeInfo = doc.getAdapter(TypeInfo.class);
      return typeInfo.getDefaultView();
    }
    return DEFAULT_VIEW;
  }
 public static Suggestion fromDocumentModel(DocumentModel doc) {
   TypeInfo typeInfo = doc.getAdapter(TypeInfo.class);
   String description = doc.getProperty("dc:description").getValue(String.class);
   String icon = null;
   if (doc.hasSchema("common")) {
     icon = (String) doc.getProperty("common", "icon");
   }
   if (StringUtils.isEmpty(icon)) {
     icon = typeInfo.getIcon();
   }
   String thumbnailURL = String.format("api/v1/id/%s/@rendition/thumbnail", doc.getId());
   return new DocumentSuggestion(doc.getId(), new DocumentLocationImpl(doc), doc.getTitle(), icon)
       .withDescription(description)
       .withThumbnailURL(thumbnailURL);
 }
 /** @deprecated this information is now held by content views */
 @Deprecated
 public List<String> getAvailableLayoutsForDocument(DocumentModel doc) {
   if (doc == null) {
     return Collections.emptyList();
   }
   TypeInfo typeInfo = doc.getAdapter(TypeInfo.class);
   String[] layoutNames = typeInfo.getLayouts(BuiltinModes.LISTING, null);
   List<String> res = new ArrayList<String>();
   if (layoutNames != null && layoutNames.length > 0) {
     res.addAll(Arrays.asList(layoutNames));
   } else {
     res.add(DEFAULT_LISTING_LAYOUT);
   }
   return res;
 }