@Override public File getFile(String path) { return FileUtils.getResourceFileFromContext(path); } },
protected Blob getDefaultThumbnail(DocumentModel doc) { if (doc == null) { return null; } TypeInfo docType = doc.getAdapter(TypeInfo.class); String iconPath = docType.getBigIcon(); if (iconPath == null) { iconPath = docType.getIcon(); } if (iconPath == null) { return null; } try { File iconFile = FileUtils.getResourceFileFromContext("nuxeo.war" + File.separator + iconPath); if (iconFile.exists()) { MimetypeRegistry mimetypeRegistry = Framework.getService(MimetypeRegistry.class); String mimeType = mimetypeRegistry.getMimetypeFromFile(iconFile); if (mimeType == null) { mimeType = mimetypeRegistry.getMimetypeFromFilename(iconPath); } return Blobs.createBlob(iconFile, mimeType); } } catch (IOException e) { log.warn(String.format("Could not fetch the thumbnail blob from icon path '%s'", iconPath), e); } return null; }
@Override public void populate(CoreSession session) { super.populate(session); DocumentModel doc = session.createDocumentModel("/", "testBlob", "File"); doc.setPropertyValue("file:content", (Serializable) Blobs.createBlob("one")); session.createDocument(doc); File docFile = FileUtils.getResourceFileFromContext("hello.doc"); DocumentModel doc2 = session.createDocumentModel("/", "testBlob2", "File"); doc2.setPropertyValue("file:content", new FileBlob(docFile)); session.createDocument(doc2); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); } }
@Override public Blob getThumbnail(DocumentModel doc, CoreSession session) { if (!doc.hasFacet(VIDEO_FACET)) { throw new NuxeoException("Document is not a video"); } // Choose the nuxeo default thumbnail of the picture views (screenshots // of the video taken during creation) PictureResourceAdapter picResAdapter = doc.getAdapter(PictureResourceAdapter.class); Blob thumbnailView = picResAdapter.getPictureFromTitle("Small"); if (thumbnailView == null) { // try Thumbnail view thumbnailView = picResAdapter.getPictureFromTitle("Thumbnail"); if (thumbnailView == null) { TypeInfo docType = doc.getAdapter(TypeInfo.class); try { return Blobs.createBlob(FileUtils.getResourceFileFromContext("nuxeo.war" + File.separator + docType.getBigIcon())); } catch (IOException e) { throw new NuxeoException(e); } } } return thumbnailView; }
@Override public Blob getThumbnail(DocumentModel doc, CoreSession session) { if (!doc.hasFacet("Picture")) { throw new NuxeoException("Document is not a picture"); } // Choose the nuxeo default thumbnail of the picture views if exists MultiviewPicture mViewPicture = doc.getAdapter(MultiviewPicture.class); PictureView thumbnailView = mViewPicture.getView("Small"); if (thumbnailView == null || thumbnailView.getBlob() == null) { // try thumbnail view thumbnailView = mViewPicture.getView("Thumbnail"); if (thumbnailView == null || thumbnailView.getBlob() == null) { TypeInfo docType = doc.getAdapter(TypeInfo.class); try { return Blobs.createBlob(FileUtils.getResourceFileFromContext("nuxeo.war" + File.separator + docType.getBigIcon())); } catch (IOException e) { throw new NuxeoException(e); } } } return thumbnailView.getBlob(); }