本文整理了Java中pl.edu.icm.model.bwmeta.y.YContentFile.getLocations()
方法的一些代码示例,展示了YContentFile.getLocations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YContentFile.getLocations()
方法的具体详情如下:
包路径:pl.edu.icm.model.bwmeta.y.YContentFile
类名称:YContentFile
方法名:getLocations
暂无
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
public void doWithFile(YContentFile yfile) {
if (contentId.equals(yfile.getId())) {
List<String> locations = yfile.getLocations();
if (locations.size() > 0) {
location = locations.iterator().next();
}
}
}
};
代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import
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;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct
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;
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-sdk-sample-services
@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);
}
}
}
代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import
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);
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
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;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
public String locateFile(final String[] idSplit) {
String fileLocation = null;
final ModelAndView content = elementContentHandler.handleContentRequest(idSplit[0], idSplit[1]);
if (content != null) {
final ContentFileInfo info = (ContentFileInfo) content.getModel().get(YaddaWebUtils.ATTR_CONTENT_FILE_INFO);
if (info != null) {
final YContentFile file = info.getContentFile();
if (file != null) {
final List<String> locations = file.getLocations();
if (CollectionUtils.isNotEmpty(locations)) {
fileLocation = locations.get(0);
}
}
}
}
return fileLocation;
}
代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import
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()) {
if (location.startsWith(BasicPackConstants.NEW_CONTENT_DIRECTORY)
||location.startsWith(BasicPackConstants.OLD_CONTENT_DIRECTORY) ||
location.startsWith(BasicPackConstants.OLD_FULLTEXTS_DIRECTORY) ){
try {
newLocations.add(bpi.contentPathToArchiveUri(location));
} catch (Exception ex) {
log.error(ex.getLocalizedMessage(), ex);
newLocations.add(location);
}
} else {
newLocations.add(location);
}
}
file.setLocations(newLocations);
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
@Override
public List<String> extractContentLocation(@SuppressWarnings("rawtypes") List<YContentEntry> contentList, String mainLevel) {
List<String> result = new ArrayList<String>();
for (YContentEntry<?> content : contentList) {
if (content instanceof YContentFile) {
YContentFile file = (YContentFile) content;
if (yModelPropertyExtractor.isFileAccepted(file, mainLevel)) {
result.add(yModelPropertyExtractor.prepareLocation(file.getLocations()));
}
} else if (content instanceof YContentDirectory) {
YContentDirectory dir = (YContentDirectory) content;
result.addAll(extractContentLocation(dir.getEntries(), mainLevel));
}
}
return result;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
protected void fillUrls(HtmlMetaHeaders metadata, ElementMetadata elementMetadata) {
YElement yElement = (YElement) elementMetadata.getContent();
Map<String, YContentFile> fulltextFiles = scanForFulltextFiles(yElement, "application/pdf", "application/octet-stream", "text/html");
if (shouldUrlBeVisible(elementMetadata)) {
for (Entry<String, YContentFile> entry : fulltextFiles.entrySet()) {
switch (entry.getKey()) {
case "application/pdf":
metadata.addMetadataName(WP_PDF_URL, constructContentPath(yElement, entry.getValue().getLocations().iterator().next()));
break;
default:
metadata.addMetadataName(WP_FULLTEXT_HTML_URL, constructContentPath(yElement, entry.getValue().getLocations().iterator().next()));
break;
}
}
}
metadata.addMetadataName(WP_ABSTRACT_URL, constructResourceUrl(yElement));
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
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;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
private Page resolveMultiFile(YContentDirectory dir) {
Page result = new Page();
if (dir.getType().equals(YConstants.CONTENT_MULTI_TYPE)) {
for (YContentEntry e : dir.getEntries()) {
if (e.isFile()) {
YContentFile file = (YContentFile) e;
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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct
@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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private String extractTextFromYElement(final YElement yElement) throws IOException {
final String sep = " ";
final YLanguage lang = YLanguage.Polish;
StringBuilder builder = new StringBuilder();
for (YName data : yElement.getNames()) {
if(lang.equals(data.getLanguage())){
builder.append(data.getText());
builder.append(sep);
}
}
for (YDescription data : yElement.getDescriptions()) {
if(lang.equals(data.getLanguage())){
builder.append(data.getText());
builder.append(sep);
}
}
for(FilteredContentEntry<?> plainTextFile:ResourceDisplayUtilsImpl.fetchPlainTextContentEntries(yElement)){
if(plainTextFile.getSource() instanceof YContentFile){
YContentFile file = (YContentFile)plainTextFile.getSource();
ElementContent elementContent = repositoryFacade.fetchContent(yElement.getId(), file.getLocations().get(0));
builder.append(IOUtils.toString(elementContent.getStream()));
builder.append(sep);
}
}
return builder.toString().trim();
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
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;
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
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);
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
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;
}
内容来源于网络,如有侵权,请联系作者删除!