@Override public boolean accept(YContentEntry<?> contentEntry) { if (contentEntry instanceof YContentDirectory) { return true; } YContentFile file = (YContentFile) contentEntry; boolean result = FileTypes.FT_PLAIN_TEXT.equals(file.getType()); hasFiles = hasFiles || result; return result; }
@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; }
public List<YContentFile> findAllThumbnailLocations(AbstractElementInfo<?> element) { final List<YContentFile> contentFiles = new ArrayList<>(); contentBrowser.browse(element, file -> { switch (file.getType()) { case FileTypes.FT_COVER: case FileTypes.FT_THUMBNAIL: contentFiles.add(file); default: } }); return contentFiles; }
@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 prepareVideoId(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.getLocations().get(0); } } } return null; }
@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; }
protected String findLocationOfContentLink(List<YContentEntry> contents, String expectedType) { for (YContentEntry content : contents) { if (content instanceof YContentFile) { YContentFile contentFile = (YContentFile) content; if (expectedType.equals(contentFile.getType())) { List<String> locations = contentFile.getLocations(); if (locations != null && locations.size() > 0) { return locations.get(0).trim(); } } } } return null; }
protected YContentFile findCover(YContentEntry<?> entry) { if (entry instanceof YContentDirectory) { YContentDirectory directory = (YContentDirectory) entry; for (YContentEntry<?> child : directory.getEntries()) { YContentFile cover = findCover(child); if (cover != null) { return cover; } } } else if (entry instanceof YContentFile) { YContentFile file = (YContentFile) entry; if (FileTypes.FT_COVER.equals(file.getType()) || FileTypes.FT_THUMBNAIL.equals(file.getType())) { return file; } } return null; }
@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); } }
protected String resolveCoverUrl(YElement element) { for (YContentEntry e : element.getContents()) { if (e.isFile()) { YContentFile cFile = (YContentFile) e; String location = cFile.getLocations().get(0); if (location != null && ((cFile.getType() != null && cFile.getType().equals("cover") || anyContentAsCover))) { return "download/" + location.replace("yar://", ""); } } } return null; }
@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); } }
@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; }
public static String getFullArchiveFileName(String elementId, YContentFile file) { String fileName = "archive/" + elementId + "/content/" + file.getType() + "/" +( file.getOneName(YConstants.NM_FILE_NAME).getText().replaceAll("[^-a-zA-Z0-9+&@#/%=~_|\\.]","_" )); return fileName; }
public static String getFullArchiveFileName(String elementId, YContentFile file) { String fileName = "archive/" + elementId + "/content/" + file.getType() + "/" +( file.getOneName(YConstants.NM_FILE_NAME).getText().replaceAll("[^-a-zA-Z0-9+&@#/%=~_|\\.]","_" )); return fileName; }
private List<YContentFile> processPlainTextEntry(final YContentEntry<?> yEntry) { final List<YContentFile> result = new ArrayList<YContentFile>(); if (yEntry.isDirectory()) { final YContentDirectory yDirectory = (YContentDirectory) yEntry; for (final YContentEntry<?> yChild : yDirectory.getEntries()) { result.addAll(processPlainTextEntry(yChild)); } } else if (yEntry.isFile() && YConstants.FT_PLAIN_TEXT.equals(((YContentFile) yEntry).getType())) { result.add((YContentFile) yEntry); } return result; }
@Override public void doWithFile(YContentFile file) { String type = file.getType(); if (FileTypes.FT_PLAIN_TEXT.equals(type)) { String location = file.getLocations().get(0); // System.out.println("adding..."+location); if (location != null) { Attachment<?> part = document.getAttachments().get(location); String text = ""; if (part instanceof BinaryAttachment) { byte[] content = ((BinaryAttachment) part).getContent(); text = new String(content); } textBuilder.append(text); } } }
private Page resolveFile(YContentFile file) { Page result = new Page(); if (!file.getLocations().isEmpty()) { String location = file.getLocations().get(0).replace("yar://", ""); if (file.getType().equals(YConstants.FT_PLAIN_TEXT)) { result.setText(location); } else { result.setScan(location); } } return result; }
private boolean isLicensedContent(ElementMetadata elementMetadata, String contentPath) { YElement yElement = (YElement) elementMetadata.getContent(); for (YContentEntry<?> entry : yElement.getContents()) { if (entry.isFile()) { YContentFile contentFile = (YContentFile) entry; if (contentFile.getLocations().contains(contentPath) && notLicensedContentTypes != null && notLicensedContentTypes.contains(contentFile.getType())) { return false; } } } return true; }
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); }