@Override
 public Serializable getReference(Object entity) throws IllegalStateException {
   checkConfig();
   DocumentModel entry = null;
   if (entity != null) {
     if (entity instanceof DirectoryEntry) {
       entry = ((DirectoryEntry) entity).getDocumentModel();
     } else if (entity instanceof DocumentModel) {
       entry = (DocumentModel) entity;
     }
     if (entry != null) {
       if (!entry.hasSchema(schema)) {
         return null;
       }
       String result = (String) entry.getProperty(schema, idField);
       if (hierarchical) {
         String parent = (String) entry.getProperty(schema, parentField);
         try (Session session = directory.getSession()) {
           while (parent != null) {
             entry = session.getEntry(parent);
             if (entry == null) {
               break;
             }
             result = parent + separator + result;
             parent = (String) entry.getProperty(schema, parentField);
           }
         }
       }
       return result;
     }
   }
   return null;
 }
 @Override
 public Object getAdapter(DocumentModel doc, Class<?> cls) {
   if (doc.hasFacet(PICTURE_FACET) || doc.hasSchema(PICTURE_SCHEMA_NAME)) {
     PictureResourceAdapter adapter = new NoPictureAdapter();
     adapter.setDocumentModel(doc);
     return adapter;
   }
   return null;
 }
 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);
 }