本文整理汇总了Java中com.liferay.portlet.documentlibrary.model.DLFileEntry.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java DLFileEntry.getExtension方法的具体用法?Java DLFileEntry.getExtension怎么用?Java DLFileEntry.getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portlet.documentlibrary.model.DLFileEntry
的用法示例。
在下文中一共展示了DLFileEntry.getExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addZipEntry
import com.liferay.portlet.documentlibrary.model.DLFileEntry; //导入方法依赖的package包/类
@Override
public String addZipEntry(LearningActivity actividad, Long assetEntryId,PortletDataContext context, Element entryElementLoc)
throws PortalException, SystemException {
AssetEntry docAsset= AssetEntryLocalServiceUtil.getAssetEntry(assetEntryId);
log.info("mimeType: " + docAsset.getMimeType());
DLFileEntry docfile=DLFileEntryLocalServiceUtil.getDLFileEntry(docAsset.getClassPK());
log.info("docFile: " + docfile.getFileEntryId());
String extension = "";
if(!docfile.getTitle().endsWith(docfile.getExtension()) && docfile.getExtension().equals("")){
if(docfile.getMimeType().equals("image/jpeg")){
extension= ".jpg";
}else if(docfile.getMimeType().equals("image/png")){
extension= ".png";
}else if(docfile.getMimeType().equals("video/mpeg")){
extension= ".mpeg";
}else if(docfile.getMimeType().equals("application/pdf")){
extension= ".pdf";
}else{
String ext[] = extension.split("/");
if(ext.length>1){
extension = ext[1];
}
}
}else if(!docfile.getTitle().endsWith(docfile.getExtension()) && !docfile.getExtension().equals("")){
extension="."+docfile.getExtension();
}
log.info("file Title: " + docfile.getTitle());
String title = changeSpecialCharacter(docfile.getTitle());
title += extension;
log.info("title: " + title);
String pathqu = getEntryPath(context, docfile);
String pathFile = getFilePath(context, docfile,actividad.getActId());
Element entryElementfe= entryElementLoc.addElement("dlfileentry");
entryElementfe.addAttribute("path", pathqu);
entryElementfe.addAttribute("file", pathFile+title);
context.addZipEntry(pathqu, docfile);
log.info("pathqu: " + pathqu);
log.info("pathFile: " + pathFile);
//Guardar el fichero en el zip.
InputStream input = DLFileEntryLocalServiceUtil.getFileAsStream(docfile.getUserId(), docfile.getFileEntryId(), docfile.getVersion());
context.addZipEntry(getFilePath(context, docfile,actividad.getActId())+title, input);
String txt = (actividad.getTypeId() == 2) ? "external":"internal";
log.info(" - Resource "+ txt + ": " + title);
return null;
}
示例2: cloneFile
import com.liferay.portlet.documentlibrary.model.DLFileEntry; //导入方法依赖的package包/类
private long cloneFile(long entryId, LearningActivity actNew, long userId, ServiceContext serviceContext){
long assetEntryId = 0;
boolean addGroupPermissions = serviceContext.isAddGroupPermissions();
try {
if(log.isDebugEnabled()){log.debug("EntryId: "+entryId);}
AssetEntry docAsset = AssetEntryLocalServiceUtil.getAssetEntry(entryId);
//docAsset.getUrl()!=""
//DLFileEntryLocalServiceUtil.getDLFileEntry(fileEntryId)
if(log.isDebugEnabled()){log.debug(docAsset.getClassPK());}
DLFileEntry docfile = DLFileEntryLocalServiceUtil.getDLFileEntry(docAsset.getClassPK());
InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(userId, docfile.getFileEntryId(), docfile.getVersion());
//Crear el folder
DLFolder dlFolder = DLFolderUtil.createDLFoldersForLearningActivity(userId, serviceContext.getScopeGroupId(), serviceContext);
long repositoryId = DLFolderConstants.getDataRepositoryId(actNew.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
String ficheroStr = docfile.getTitle();
if(!docfile.getTitle().endsWith(docfile.getExtension())){
ficheroStr = ficheroStr +"."+ docfile.getExtension();
}
serviceContext.setAddGroupPermissions(true);
FileEntry newFile = DLAppLocalServiceUtil.addFileEntry(
serviceContext.getUserId(), repositoryId , dlFolder.getFolderId() , ficheroStr, docfile.getMimeType(),
docfile.getTitle(), StringPool.BLANK, StringPool.BLANK, is, docfile.getSize() , serviceContext ) ;
AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), newFile.getPrimaryKey());
if(log.isDebugEnabled()){log.debug(" asset : " + asset.getEntryId());};
assetEntryId = asset.getEntryId();
} catch (NoSuchEntryException nsee) {
log.error(" asset not exits ");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
serviceContext.setAddGroupPermissions(addGroupPermissions);
}
return assetEntryId;
}