@Override protected void addViews(List<Map<String, Object>> pictureTemplates, String filename, String title) throws IOException, NuxeoException { /* positionner à null le paramètre pictureTemplates pour que les valeurs par défaut soient utilisées * (voir le ticket Jira #7654 - https://jira.nuxeo.com/browse/SUPNXP-7654) */ List<Map<String, Object>> picTpls = (null != pictureTemplates && pictureTemplates.isEmpty()) ? null : pictureTemplates; super.addViews(picTpls, filename, title); }
@Override public String getFirstViewXPath() { return getViewXPathFor(0); }
List<Map<String, Object>> pictureConversions) throws IOException { if (blob == null) { clearViews(); return true; if (type == null || type.equals("application/octet-stream")) { type = getImagingService().getImageMimeType(file); blob.setMimeType(type); ImageInfo imageInfo = getImageInfo(); if (imageInfo != null) { doc.setPropertyValue(PICTURE_INFO_PROPERTY, (Serializable) imageInfo.toMap()); clearViews(); addViews(pictureConversions, filename, title);
@Override public void preFillPictureViews(Blob blob, List<Map<String, Object>> pictureConversions, ImageInfo imageInfo) throws IOException { ImagingService imagingService = getImagingService(); List<PictureView> pictureViews; if (pictureConversions != null) { List<PictureConversion> conversions = new ArrayList<>(pictureConversions.size()); for (Map<String, Object> template : pictureConversions) { conversions.add(new PictureConversion((String) template.get("title"), (String) template.get("description"), (String) template.get("tag"), 0)); } pictureViews = imagingService.computeViewsFor(blob, conversions, imageInfo, false); } else { pictureViews = imagingService.computeViewsFor(doc, blob, imageInfo, false); } addPictureViews(pictureViews, true); }
@Override public Object getAdapter(DocumentModel doc, Class cls) { if (doc.hasFacet(PICTURE_FACET) || doc.hasSchema(PICTURE_SCHEMA_NAME)) { PictureResourceAdapter adapter = new DefaultPictureAdapter(); adapter.setDocumentModel(doc); return adapter; } return null; }
@Override public void doRotate(int angle) { int size = doc.getProperty(VIEWS_PROPERTY).size(); for (int i = 0; i < size; i++) { String xpath = "picture:views/view[" + i + "]/"; BlobHolder blob = new SimpleBlobHolder(doc.getProperty(xpath + "content").getValue(Blob.class)); String type = blob.getBlob().getMimeType(); if (!"image/png".equals(type)) { Map<String, Serializable> options = new HashMap<>(); options.put(ImagingConvertConstants.OPTION_ROTATE_ANGLE, angle); blob = getConversionService().convert(ImagingConvertConstants.OPERATION_ROTATE, blob, options); doc.getProperty(xpath + "content").setValue(blob.getBlob()); Long height = (Long) doc.getProperty(xpath + "height").getValue(); Long width = (Long) doc.getProperty(xpath + "width").getValue(); doc.getProperty(xpath + "height").setValue(width); doc.getProperty(xpath + "width").setValue(height); } } }
@Override public String getViewXPath(String viewName) { Property views = doc.getProperty(VIEWS_PROPERTY); for (int i = 0; i < views.size(); i++) { if (views.get(i).getValue(TITLE_PROPERTY).equals(viewName)) { return getViewXPathFor(i); } } return null; }