private void prepareCover(YElement element, String location, String mimeType, String fileId) { List<String> locations = new ArrayList<String>(); locations.add(fileId); locations.add(location); YContentFile newCover = new YContentFile(fileId, FileTypes.FT_COVER, mimeType, locations); element.getContents().add(newCover); }
protected YContentFile getContentFile(Link link) { String name = link.getHref(); name = StringUtils.removeStart(name, WileyComponentConstants.CONENT_LINK_PREFIX); name = StringUtils.stripStart(name, "/\\"); YContentFile contentFile = new YContentFile(name, FileTypes.FT_FULL_TEXT, "application/pdf", null); contentFile.getLocations().add(name); return contentFile; } }
YContentFile buildYContentFile() { YContentFile yContentFile = new YContentFile(String.valueOf(id), FileTypes.FT_FULL_TEXT, format, Lists.newArrayList(location)); YName yName = new YName(name); yName.setType(NameTypes.NM_FILE_NAME); yContentFile.addName(yName); return yContentFile; }
private void prepareContent(Video video, YElement yElement) { YContentFile viedoUrlContnent = new YContentFile(video.getId(), VideoConstants.VIDEO_URL_FILE_TYPE, VideoConstants.YOUTUBE_FORMAT, Collections.singletonList(video.getId())); yElement.addContent(viedoUrlContnent); String thumbnailUrl = parseThumbnailUrl(video); if (thumbnailUrl != null) { // TODO format detect YContentFile thumbnailContent = new YContentFile(video.getId() + "_thumbnail", FileTypes.FT_THUMBNAIL, MediaType.ANY_IMAGE_TYPE.toString(), Collections.singletonList(thumbnailUrl)); yElement.addContent(thumbnailContent); } }
/** * Creates a content file given its required properties. * If some of the specified values are empty or null, does not create a content file * but returns null. If some, but not all, of the specified locations are empty or null they are * not used. * * @param id file identifier * @param type type of content * @param mime MIME type of the file * @param locations URLs for the locations of the file, empty and null locations are omitted * @return created content file, or null if some input was empty or missing */ public YContentFile contentFile(String id, String type, String mime, String... locations) { if (empty(id) || empty(type) || empty(mime)) return null; ArrayList<String> ls = new ArrayList<String>(locations.length); for (String l : locations) if (!empty(l)) ls.add(l); if (ls.isEmpty()) return null; return new YContentFile(id, type, mime, ls); }
private void appendContents(ResourceData resource, YElement yElement) { for (ResourceData.ResourceFileData content : resource.getContents()) { if (!content.isToBeDeleted()) { final String fileId = content.getId(); final String fileName = content.getName(); if (!checkIfContentPresent(yElement, fileId)) { String mime = ExtendedMimeTypeHelper.resolveTypeForFile(fileName != null ? new File(fileName) : null); List<String> locations = Collections.singletonList(content.getLocation()); yElement.addContent(new YContentFile(fileId, content.getType(), mime, locations).addName(new YName(fileName))); } } } }
private Document prepareContentAndSpeechToText(PlatonTVFile input, String id, RecordId recordId, YElement yElement) { String transliterationPartId = UUID.randomUUID().toString(); YContentFile viedoContnentUrl = new YContentFile(id + "_" + transliterationPartId, VideoConstants.VIDEO_URL_FILE_TYPE, "pionierFormat", Collections.singletonList(id)); yElement.addContent(viedoContnentUrl); try { document.addBinaryAttachment(transliterationPartId, FileUtils.readFileToByteArray(input.getSpeechToTextFile())); YContentFile viedoSpeechToTextContent = new YContentFile(id + "_text_" + transliterationPartId, FileTypes.FT_FULL_TEXT, "plain/text", Collections.singletonList(transliterationPartId)); yElement.addContent(viedoSpeechToTextContent);
ocrContent = new YContentFile(); contentPartName = idGenerator.generate(); ocrContent.addLocation(contentPartName);
article.addContent(new YContentFile().addLocation(aid.getTextTrim()));
YContentFile description = new YContentFile(); description.setAttributes(template.getAttributes()); description.setDescriptions(template.getDescriptions());
YContentFile description = new YContentFile(); description.setAttributes(template.getAttributes()); description.setDescriptions(template.getDescriptions());