Search in sources :

Example 1 with DLFileEntry

use of com.liferay.portlet.documentlibrary.model.DLFileEntry in project liferay-ide by liferay.

the class AlbumStagedModelDataHandler method _getContentStream.

private InputStream _getContentStream(FileEntry fileEntry) throws PortalException, SystemException {
    long repositoryId = DLFolderConstants.getDataRepositoryId(fileEntry.getRepositoryId(), fileEntry.getFolderId());
    String name = ((DLFileEntry) fileEntry.getModel()).getName();
    InputStream is = DLStoreUtil.getFileAsStream(fileEntry.getCompanyId(), repositoryId, name, fileEntry.getVersion());
    if (is == null) {
        is = new UnsyncByteArrayInputStream(new byte[0]);
    }
    return is;
}
Also used : UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream) InputStream(java.io.InputStream) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream)

Example 2 with DLFileEntry

use of com.liferay.portlet.documentlibrary.model.DLFileEntry in project liferay-ide by liferay.

the class ArtistStagedModelDataHandler method _getContentStream.

private InputStream _getContentStream(FileEntry fileEntry) throws PortalException, SystemException {
    long repositoryId = DLFolderConstants.getDataRepositoryId(fileEntry.getRepositoryId(), fileEntry.getFolderId());
    String name = ((DLFileEntry) fileEntry.getModel()).getName();
    InputStream is = DLStoreUtil.getFileAsStream(fileEntry.getCompanyId(), repositoryId, name, fileEntry.getVersion());
    if (is == null) {
        is = new UnsyncByteArrayInputStream(new byte[0]);
    }
    return is;
}
Also used : UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream) InputStream(java.io.InputStream) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream)

Example 3 with DLFileEntry

use of com.liferay.portlet.documentlibrary.model.DLFileEntry in project liferay-ide by liferay.

the class WebServerServlet method isLegacyImageGalleryImageId.

protected boolean isLegacyImageGalleryImageId(HttpServletRequest request, HttpServletResponse response) {
    try {
        long imageId = getImageId(request);
        if (imageId == 0) {
            return false;
        }
        DLFileEntry dlFileEntry = DLFileEntryServiceUtil.fetchFileEntryByImageId(imageId);
        if (dlFileEntry == null) {
            return false;
        }
        StringBundler sb = new StringBundler(9);
        sb.append("/documents/");
        sb.append(dlFileEntry.getGroupId());
        sb.append(StringPool.SLASH);
        sb.append(dlFileEntry.getFolderId());
        sb.append(StringPool.SLASH);
        sb.append(HttpUtil.encodeURL(HtmlUtil.unescape(dlFileEntry.getTitle()), true));
        sb.append("?version=");
        sb.append(dlFileEntry.getVersion());
        if (imageId == dlFileEntry.getSmallImageId()) {
            sb.append("&imageThumbnail=1");
        } else if (imageId == dlFileEntry.getSmallImageId()) {
            sb.append("&imageThumbnail=2");
        } else if (imageId == dlFileEntry.getSmallImageId()) {
            sb.append("&imageThumbnail=3");
        }
        response.setHeader(HttpHeaders.LOCATION, sb.toString());
        response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
        return true;
    } catch (Exception e) {
    }
    return false;
}
Also used : DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry) StringBundler(com.liferay.portal.kernel.util.StringBundler) ServletException(javax.servlet.ServletException) RepositoryException(com.liferay.portal.kernel.repository.RepositoryException) NoSuchFileEntryException(com.liferay.portlet.documentlibrary.NoSuchFileEntryException) NoSuchFolderException(com.liferay.portlet.documentlibrary.NoSuchFolderException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) IOException(java.io.IOException) NoSuchGroupException(com.liferay.portal.NoSuchGroupException)

Example 4 with DLFileEntry

use of com.liferay.portlet.documentlibrary.model.DLFileEntry in project liferay-ide by liferay.

the class ArtistIndexer method addRelatedEntryFields.

@Override
public void addRelatedEntryFields(Document document, Object obj) throws Exception {
    if (obj instanceof DLFileEntry) {
        DLFileEntry dlFileEntry = (DLFileEntry) obj;
        Artist artist = ArtistLocalServiceUtil.getArtist(GetterUtil.getLong(dlFileEntry.getTitle()));
        document.addKeyword(Field.CLASS_NAME_ID, PortalUtil.getClassNameId(Artist.class.getName()));
        document.addKeyword(Field.CLASS_PK, artist.getArtistId());
        document.addKeyword(Field.RELATED_ENTRY, true);
    }
}
Also used : Artist(org.liferay.jukebox.model.Artist) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry)

Example 5 with DLFileEntry

use of com.liferay.portlet.documentlibrary.model.DLFileEntry in project liferay-ide by liferay.

the class SongIndexer method addRelatedEntryFields.

@Override
public void addRelatedEntryFields(Document document, Object obj) throws Exception {
    if (obj instanceof DLFileEntry) {
        DLFileEntry dlFileEntry = (DLFileEntry) obj;
        Song song = SongLocalServiceUtil.getSong(GetterUtil.getLong(dlFileEntry.getTitle()));
        document.addKeyword(Field.CLASS_NAME_ID, PortalUtil.getClassNameId(Song.class.getName()));
        document.addKeyword(Field.CLASS_PK, song.getSongId());
        document.addKeyword(Field.RELATED_ENTRY, true);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry)

Aggregations

DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)5 UnsyncByteArrayInputStream (com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream)2 InputStream (java.io.InputStream)2 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)1 StringBundler (com.liferay.portal.kernel.util.StringBundler)1 PrincipalException (com.liferay.portal.security.auth.PrincipalException)1 NoSuchFileEntryException (com.liferay.portlet.documentlibrary.NoSuchFileEntryException)1 NoSuchFolderException (com.liferay.portlet.documentlibrary.NoSuchFolderException)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 Artist (org.liferay.jukebox.model.Artist)1 Song (org.liferay.jukebox.model.Song)1