public void addFile(Entry file) { if (!this.files.contains(file)) { this.files.add(file); } else { log.warn("Trying to add second file: "+file.description.getId()+" skipping"); } }
public void addFile(Entry file) { if (!this.files.contains(file)) { this.files.add(file); } else { log.warn("Trying to add second file: "+file.description.getId()+" skipping"); } }
private boolean checkIfContentPresent(final YElement yElement, final String fileId) { for (YContentEntry<?> content : yElement.getContents()) { if (content instanceof YContentFile) { if (StringUtils.equals(((YContentFile) content).getId(), fileId)) { return true; } } } return false; }
@Override public void doWithFile(YContentFile yfile) { if (contentId.equals(yfile.getId())) { List<String> locations = yfile.getLocations(); if (locations.size() > 0) { location = locations.iterator().next(); } } } };
@SuppressWarnings("rawtypes") private YContentFile findYContentFileById(Iterable<YContentEntry> contents, String id) { for (YContentEntry<?> contentEntry : contents) { if (contentEntry instanceof YContentFile) { YContentFile contentFile = (YContentFile) contentEntry; if (contentFile.getId().equals(id)) { return contentFile; } } else { YContentDirectory directory = (YContentDirectory) contentEntry; return findYContentFileById(directory.getEntries(), id); } } 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(); } }
private FLocat createContentLocation(String elementId, YContentFile yfile) { FLocat fLocat = new FLocat(); fLocat.setLOCTYPE("HANDLE"); fLocat.setHref(yfile.getId()); return fLocat; }
@Override public DataResponse apply(YElement input) { ZipFile zipFile = processorState.getZipFile(); ZipEntry lastEntry = processorState.getLastZipEntry(); YAttribute attribute = new YAttribute(CommonExtractorContstants.SOURCE_ATTRIBUTE, zipFile.getName() + "/" + lastEntry.getName()); input.getAttributes().add(attribute); DataResponse dataResponse = new DataResponse(input, dataResponseQualityComparator); for (YContentFile file : createIterable(input.getContents())) { String id = file.getId(); String fileName = file.getLocations().get(0); ZipEntry entry = zipFile.getEntry(fileName); if (entry != null) { dataResponse.addContent(id, new ZipEntryResource(zipFile.getName(), entry)); } } if(insertSource){ dataResponse.addContent(CommonExtractorContstants.SOURCE_ATTRIBUTE, new ZipEntryResource(zipFile.getName(), lastEntry)); } return dataResponse; }
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); }
id = Long.parseLong(file.getId()); } catch (NumberFormatException ex) { id = 0;
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.setDescriptions(template.getDescriptions()); description.setFormat(template.getFormat()); description.setId(template.getId()); description.setLanguages(template.getLanguages()); description.setLocations(template.getLocations());
description.setDescriptions(template.getDescriptions()); description.setFormat(template.getFormat()); description.setId(template.getId()); description.setLanguages(template.getLanguages()); description.setLocations(template.getLocations());
final String fileName = file.getOneName().getText(); final String location = file.getLocations().get(0); result.addContent(new ResourceData.ResourceFileData(file.getId(), fileName, location, file.getType()));