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); }
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; } }
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; }
@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 String extractId(YContentFile yFile) { YName fileNameCandidate = yFile.getOneName(NameTypes.NM_FILE_NAME); if (fileNameCandidate == null) { fileNameCandidate = yFile.getOneName(); } if (fileNameCandidate == null) { return yFile.getId(); } else { return fileNameCandidate.getText(); } }
for (YTypedString signature : template.getSignatures()) { if (YConstants.SG_MD5.equals(signature.getType())) { hasMD5 = true; digestString.append(hexArray[0xFF & b]); template.addSignature(new YTypedString(YConstants.SG_MD5, digestString.toString())); } catch (NoSuchAlgorithmException e) { YContentFile description = new YContentFile(); description.setAttributes(template.getAttributes()); description.setDescriptions(template.getDescriptions()); description.setFormat(template.getFormat()); description.setId(template.getId()); description.setLanguages(template.getLanguages()); description.setLocations(template.getLocations()); description.setNames(template.getNames()); description.setSignatures(template.getSignatures()); description.setSize(template.getSize()); description.setType(template.getType()); description.addLocation(YConstants.MISC_PACK_RELATIVE_CONTENT_PREFIX + fileName);
if (yContentEntry.isFile()) { YContentFile file = (YContentFile) yContentEntry; String type = file.getType(); if (ocrContentType.equals(type) && format.equalsIgnoreCase(file.getFormat())) { ocrContentFound = true; ocrContent = file; List<String> locations = file.getLocations(); if (locations.size() == 1) { contentPartName = locations.iterator().next(); ocrContent = new YContentFile(); contentPartName = idGenerator.generate(); ocrContent.addLocation(contentPartName); ocrContent.setType(DEFAULT_CONTENT_TYPE); ocrContent.setId(contentPartName); element.addContent(ocrContent); ocrContent.setFormat(format); ocrContent.getNames().clear(); ocrContent.addName(name);
@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; }
String fAddress = null; for (String loc : file.getLocations()) { boolean visible = true, remote = true; String address = null; id = Long.parseLong(file.getId()); } catch (NumberFormatException ex) { id = 0; String resolvedType = resolveFileType(file.getFormat()); //temporary solution while DL won't support audio/video if (!"audio".equals(resolvedType) && !"video".equals(resolvedType)) { resolvedType = file.getType(); if (YConstants.CONTENT_MULTI_TYPE.equals(parent) || file.getDefaultName() == null) { descr = pdescr = mimeTypeDictionary.getName(file.getFormat(), LocaleContextHolder.getLocale()); } else { descr = detailsFilter.filter( YRTHelper.toXmlFragment(file.getDefaultName().getRichText()), InputType.RICH_TEXT, filteringContext); pdescr = detailsFilter.filter(file.getDefaultName().getText(), InputType.PLAIN_TEXT, filteringContext); String mimeIcon = detailsFilter.filter(mimeIcon(file.getFormat()), InputType.IDENTIFIER, filteringContext);
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; }
if (content instanceof YContentFile) { YContentFile file = (YContentFile) content; final String fileName = file.getOneName().getText(); final String location = file.getLocations().get(0); result.addContent(new ResourceData.ResourceFileData(file.getId(), fileName, location, file.getType()));
private String findThumbnailLocation(AbstractElementInfo<?> element) { final List<YContentFile> contentFiles = findAllThumbnailLocations(element); for (YContentFile contentFile : contentFiles) { if (contentFile.getLocations().isEmpty()) { continue; } return contentFile.getLocations().get(0); } return null; }
@Override public void doWithFile(YContentFile yfile) { if (contentId.equals(yfile.getId())) { List<String> locations = yfile.getLocations(); if (locations.size() > 0) { location = locations.iterator().next(); } } } };
if (file != null) { final String mimeType; if(StringUtils.isNotBlank(file.getFormat())){ mimeType = file.getFormat(); } else { String location = file.getLocations().get(0); int lastDot = location.lastIndexOf("."); if(lastDot != -1){ binaryAttachment.addTagByKey(TAG_NAME_CONTENT_NAME, file.getLocations().get(0)); } else { binaryAttachment.addTagByKey(TAG_NAME_CONTENT_NAME, resource.getDescription());
@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; }
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); }
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); } } }
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; }
public void convertContentLocations(YContentEntry<?> entry) { if (entry instanceof YContentDirectory) { YContentDirectory dir = (YContentDirectory) entry; for (YContentEntry<?> e : dir.getEntries()) { convertContentLocations(e); } return; } YContentFile file = (YContentFile) entry; List<String> newLocations = new ArrayList<String>(); for (String location : file.getLocations()) { newLocations.add(location.replaceAll("^" + YConstants.MISC_PACK_RELATIVE_CONTENT_PREFIX + "archive/", YConstants.MISC_LOCAL_CONTENT_ADDRESS_PREFIX)); } file.setLocations(newLocations); }