Search in sources :

Example 31 with FileEntry

use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.

the class ShindigUtil method getFileEntryURL.

public static String getFileEntryURL(String portalURL, long fileEntryId) throws PortalException, SystemException {
    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    StringBundler sb = new StringBundler(6);
    sb.append(portalURL);
    sb.append(PortalUtil.getPathContext());
    sb.append("/documents/");
    sb.append(fileEntry.getRepositoryId());
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getUuid());
    return sb.toString();
}
Also used : FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 32 with FileEntry

use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.

the class KBArticleStagedModelDataHandler method exportKBArticleAttachments.

protected void exportKBArticleAttachments(PortletDataContext portletDataContext, Element kbArticleElement, KBArticle kbArticle) throws Exception {
    List<FileEntry> attachmentsFileEntries = kbArticle.getAttachmentsFileEntries();
    for (FileEntry fileEntry : attachmentsFileEntries) {
        String path = ExportImportPathUtil.getModelPath(kbArticle, fileEntry.getTitle());
        Element fileEntryElement = portletDataContext.getExportDataElement(fileEntry);
        fileEntryElement.addAttribute("path", path);
        fileEntryElement.addAttribute("file-name", fileEntry.getTitle());
        portletDataContext.addZipEntry(path, fileEntry.getContentStream());
        portletDataContext.addReferenceElement(kbArticle, kbArticleElement, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK, false);
    }
}
Also used : Element(com.liferay.portal.kernel.xml.Element) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry)

Example 33 with FileEntry

use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.

the class AdminSubscriptionSender method getEmailKBArticleAttachments.

protected String getEmailKBArticleAttachments(Locale locale) throws Exception {
    List<FileEntry> attachmentsFileEntries = _kbArticle.getAttachmentsFileEntries();
    if (attachmentsFileEntries.isEmpty()) {
        return StringPool.BLANK;
    }
    StringBundler sb = new StringBundler(attachmentsFileEntries.size() * 5);
    for (FileEntry fileEntry : attachmentsFileEntries) {
        sb.append(fileEntry.getTitle());
        sb.append(" (");
        sb.append(TextFormatter.formatStorageSize(fileEntry.getSize(), locale));
        sb.append(")");
        sb.append("<br />");
    }
    return sb.toString();
}
Also used : FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 34 with FileEntry

use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-blade-samples by liferay.

the class BladeActionConfigurationIcon method _retrieveFile.

private FileEntry _retrieveFile(HttpServletRequest request) {
    try {
        long fileEntryId = ParamUtil.getLong(request, "fileEntryId");
        FileEntry fileEntry = null;
        if (fileEntryId > 0) {
            fileEntry = _dlAppService.getFileEntry(fileEntryId);
        }
        if (fileEntry == null) {
            return null;
        }
        String cmd = ParamUtil.getString(request, Constants.CMD);
        if (fileEntry.isInTrash() && !cmd.equals(Constants.MOVE_FROM_TRASH)) {
            return null;
        }
        return fileEntry;
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
        return null;
    }
}
Also used : FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException)

Aggregations

FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)34 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)15 PortalException (com.liferay.portal.kernel.exception.PortalException)8 Folder (com.liferay.portal.kernel.repository.model.Folder)7 ServiceContext (com.liferay.portal.service.ServiceContext)6 IOException (java.io.IOException)6 SystemException (com.liferay.portal.kernel.exception.SystemException)5 JSONObject (com.liferay.portal.kernel.json.JSONObject)5 Element (com.liferay.portal.kernel.xml.Element)5 User (com.liferay.portal.model.User)5 NoSuchFileEntryException (com.liferay.portlet.documentlibrary.NoSuchFileEntryException)5 InputStream (java.io.InputStream)5 StringBundler (com.liferay.portal.kernel.util.StringBundler)4 ArrayList (java.util.ArrayList)4 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)3 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)3 FileVersion (com.liferay.portal.kernel.repository.model.FileVersion)3 Group (com.liferay.portal.model.Group)3 Repository (com.liferay.portal.model.Repository)3 PrincipalException (com.liferay.portal.security.auth.PrincipalException)3