@Override public void doWithFile(YContentFile file) { String type = file.getType(); String format = file.getFormat(); if ("application/pdf".equals(format)) { exist.set(true); } }
private boolean isFileAcceptable(YContentFile yfile) { String type = yfile.getType(); if (StringUtils.isBlank(type) || ACCEPTED_FILE_TYPES.contains(type)) { String format = yfile.getFormat(); if (format != null) { format = format.toLowerCase(); return ACCEPTED_FILE_FORMATS.contains(format); } } return false; }
@SuppressWarnings("rawtypes") private String prepareVideoFormat(List<YContentEntry> contents){ for (YContentEntry<?> yContentEntry : contents) { if(yContentEntry instanceof YContentFile){ YContentFile file = (YContentFile) yContentEntry; if(VideoConstants.VIDEO_URL_FILE_TYPE.equals(file.getType())){ return file.getFormat(); } } } return null; }
private void handleContent(DocumentDTO docDTO, @SuppressWarnings("rawtypes") YContentEntry content, ZipArchive currentZipArchive, long contentSizeLimit) { if (content.isFile()) { YContentFile yFile = (YContentFile) content; if (BWMetaConstants.mimePdfListExtension.contains(yFile.getFormat())) { fetchMediaFromZip(docDTO, yFile, currentZipArchive, ProtoConstants.mediaTypePdf, contentSizeLimit); } else if (BWMetaConstants.mimeTxtListExtension.contains(yFile.getFormat())) { fetchMediaFromZip(docDTO, yFile, currentZipArchive, ProtoConstants.mediaTypeTxt, contentSizeLimit); } } }
@Override public void doWithFile(YContentFile file) { String type = file.getType(); String format = file.getFormat(); if ("application/pdf".equals(format) && type==null) { fixed.set(true); file.setType(FileTypes.FT_FULL_TEXT); } }
@Override public boolean isFileAccepted(YContentFile content, String mainLevel) { // XXX fallback fix if (YaddaIdConstants.ID_LEVEL_JOURNAL_ARTICLE.equals(mainLevel) && StringUtils.isBlank(content.getType())) { return true; } if (acceptedFileTypes.contains(content.getType()) && !SKIPPABLE_FILE_FORMATS.contains(content.getFormat())) { return true; } return false; }
@Override public boolean accept(YContentEntry<?> contentEntry) { if (contentEntry instanceof YContentDirectory) { return true; } YContentFile file = (YContentFile) contentEntry; boolean result = ACCEPTED_FILE_TYPES.contains(file.getType()) && MediaType.PDF.toString().equals(file.getFormat()); hasFiles = hasFiles || result; return result; }
@Override public void doWithFile(YContentFile file) { String type = file.getType(); String format = file.getFormat(); if ("application/pdf".equals(format) && StringUtils.isBlank(type)) { // if ("application/pdf".equals(format) && "content".equals(type)) { fixed.set(true); file.setType(FileTypes.FT_FULL_TEXT); } }
protected void fillFormats(YElement yElement, List<YExportable> referedElements, Map<String, List<StringWithAttributes>> ret) { // format element for (YContentEntry<?> yContentEntry : yElement.getContents()) { if (yContentEntry.isFile()) { if (!ret.containsKey(E_FORMAT)) { ret.put(E_FORMAT, new ArrayList<StringWithAttributes>()); } ret.get(E_FORMAT).add(new StringWithAttributes(((YContentFile) yContentEntry).getFormat())); } } }
@SuppressWarnings("rawtypes") private Map<String, YContentFile> scanForFulltextFiles(Collection<YContentEntry> contentEntries, Set<String> formats) { Map<String, YContentFile> result = new HashMap<String, YContentFile>(); for (YContentEntry contentEntry : contentEntries) { if (contentEntry instanceof YContentFile) { YContentFile contentFile = (YContentFile) contentEntry; if (StringUtils.equals(contentFile.getType(), "full-text") && formats.contains(contentFile.getFormat())) { result.put(contentFile.getFormat(), contentFile); } } else if (contentEntry instanceof YContentDirectory) { YContentDirectory contentDirectory = (YContentDirectory) contentEntry; Map<String, YContentFile> subResult = scanForFulltextFiles(contentDirectory.getEntries(), formats); subResult.putAll(result); result = subResult; } } return result; }
protected void fillFormats(HtmlMetaHeaders metadata, YElement yElement) { for (YContentEntry<?> yContentEntry : yElement.getContents()) { if (yContentEntry.isFile()) { YContentFile yContentFile = (YContentFile) yContentEntry; metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_FORMAT, yContentFile.getFormat()); } } }
private FileType createFileType(String elementId, YContentFile yfile) { FileType fileType = new FileType(); fileType.setID(extractId(yfile)); if (yfile.getSize() != null) { fileType.setSIZE(yfile.getSize()); } if (StringUtils.isNotBlank(yfile.getFormat())) { fileType.setMIMETYPE(yfile.getFormat()); } FLocat fLocat = createContentLocation(elementId, yfile); fileType.getFLocats().add(fLocat); return fileType; }
private List<ContentFileData> findChapterPages(List<YContentEntry> chapterEntries, Locale locale, String mainLevel) { List<ContentFileData> result = new ArrayList<ContentFileData>(); for (YContentEntry<?> content : chapterEntries) { if (content instanceof YContentFile) { YContentFile file = (YContentFile) content; if (yModelPropertyExtractor.isFileAccepted(file, mainLevel)) { result.add(new ContentFileData(file.getId(), YModelUtils.getDefaultName(file), fetchName(file.getFormat(), locale), yModelPropertyExtractor.prepareLocation(file.getLocations()))); } } else if (content instanceof YContentDirectory) { YContentDirectory dir = (YContentDirectory) content; if (ContentTypes.CONTENT_MULTI_TYPE.equals(dir.getType())) { result.addAll(findChapterPages(dir.getEntries(), locale, mainLevel)); } } } return result; }
private List<ContentInfo> getContentInfo(YContentFile file){ Collection<String> names = convertNames(file.getNames()); ContentInfo contentInfo = new ContentInfo.Builder(file.getFormat(), file.getId()) .locations(file.getLocations()) .names(names) .type(file.getType()) .build(); return Arrays.asList(contentInfo); }
String resolvedType = resolveFileType(file.getFormat()); //temporary solution while DL won't support audio/video if (!"audio".equals(resolvedType) && !"video".equals(resolvedType)) { resolvedType = file.getType(); descr = pdescr = mimeTypeDictionary.getName(file.getFormat(), LocaleContextHolder.getLocale()); } else { String mimeIcon = detailsFilter.filter(mimeIcon(file.getFormat()), InputType.IDENTIFIER, filteringContext);
YContentFile file = (YContentFile) yContentEntry; String type = file.getType(); if (ocrContentType.equals(type) && format.equalsIgnoreCase(file.getFormat())) { ocrContentFound = true; ocrContent = file;
private List<ContentEntryData> translateContent(List<YContentEntry> contentList, Locale locale, String mainLevel) { List<ContentEntryData> result = new ArrayList<ContentEntryData>(); for (YContentEntry<?> content : contentList) { if (content instanceof YContentFile) { YContentFile file = (YContentFile) content; if (yModelPropertyExtractor.isFileAccepted(file, mainLevel)) { result.add(new ContentFileData(file.getId(), YModelUtils.getDefaultName(file), fetchName(file.getFormat(), locale), yModelPropertyExtractor.prepareLocation(file.getLocations()))); } } else if (content instanceof YContentDirectory) { YContentDirectory dir = (YContentDirectory) content; if (ContentTypes.CONTENT_PAGED.equals(dir.getType()) && findIfContentExists(dir.getEntries(), mainLevel)) { result.add(new ContentDirectoryData(dir.getId(), getDirectoryName(dir), dir.getType(), fetchName(dir.getType(), locale))); } else if(findIfContentExists(dir.getEntries(), mainLevel)) { result.add(new ContentDirectoryData(dir.getId(), getDirectoryName(dir), dir.getType(), fetchName(dir.getType(), locale), translateContent(dir.getEntries(), locale, mainLevel))); } } } return result; }
description.setAttributes(template.getAttributes()); description.setDescriptions(template.getDescriptions()); description.setFormat(template.getFormat()); description.setId(template.getId()); description.setLanguages(template.getLanguages());
description.setAttributes(template.getAttributes()); description.setDescriptions(template.getDescriptions()); description.setFormat(template.getFormat()); description.setId(template.getId()); description.setLanguages(template.getLanguages());