当前位置: 首页>>代码示例>>Java>>正文


Java Bookmark类代码示例

本文整理汇总了Java中net.sourceforge.subsonic.domain.Bookmark的典型用法代码示例。如果您正苦于以下问题:Java Bookmark类的具体用法?Java Bookmark怎么用?Java Bookmark使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Bookmark类属于net.sourceforge.subsonic.domain包,在下文中一共展示了Bookmark类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBookmarks

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void getBookmarks(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    Player player = playerService.getPlayer(request, response);
    String username = securityService.getCurrentUsername(request);

    Bookmarks result = new Bookmarks();
    for (Bookmark bookmark : bookmarkDao.getBookmarks(username)) {
        org.subsonic.restapi.Bookmark b = new org.subsonic.restapi.Bookmark();
        result.getBookmark().add(b);
        b.setPosition(bookmark.getPositionMillis());
        b.setUsername(bookmark.getUsername());
        b.setComment(bookmark.getComment());
        b.setCreated(jaxbWriter.convertDate(bookmark.getCreated()));
        b.setChanged(jaxbWriter.convertDate(bookmark.getChanged()));

        MediaFile mediaFile = mediaFileService.getMediaFile(bookmark.getMediaFileId());
        b.setEntry(createJaxbChild(player, mediaFile, username));
    }

    Response res = createResponse();
    res.setBookmarks(result);
    jaxbWriter.writeResponse(request, response, res);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:25,代码来源:RESTController.java

示例2: getBookmarks

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
public void getBookmarks(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    Player player = playerService.getPlayer(request, response);
    String username = securityService.getCurrentUsername(request);

    XMLBuilder builder = createXMLBuilder(request, response, true);

    builder.add("bookmarks", false);
    for (Bookmark bookmark : bookmarkDao.getBookmarks(username)) {
        builder.add("bookmark", createAttributesForBookmark(bookmark), false);
        MediaFile mediaFile = mediaFileService.getMediaFile(bookmark.getMediaFileId());
        AttributeSet attributes = createAttributesForMediaFile(player, mediaFile, username);
        builder.add("entry", attributes, true);
        builder.end();
    }
    builder.endAll();
    response.getWriter().print(builder);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:19,代码来源:RESTController.java

示例3: createBookmark

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void createBookmark(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    String username = securityService.getCurrentUsername(request);
    int mediaFileId = getRequiredIntParameter(request, "id");
    long position = getRequiredLongParameter(request, "position");
    String comment = request.getParameter("comment");
    Date now = new Date();

    Bookmark bookmark = new Bookmark(0, mediaFileId, position, username, comment, now, now);
    bookmarkDao.createOrUpdateBookmark(bookmark);
    refreshBookmarkCache();
    writeEmptyResponse(request, response);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:15,代码来源:RESTController.java

示例4: createOrUpdateBookmark

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
/**
 * Creates or updates a bookmark.  If created, the ID of the bookmark will be set by this method.
 */
public synchronized void createOrUpdateBookmark(Bookmark bookmark) {
    int n = update("update bookmark set position_millis=?, comment=?, changed=? where media_file_id=? and username=?",
            bookmark.getPositionMillis(), bookmark.getComment(), bookmark.getChanged(), bookmark.getMediaFileId(), bookmark.getUsername());

    if (n == 0) {
        update("insert into bookmark (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")", null,
                bookmark.getMediaFileId(), bookmark.getPositionMillis(), bookmark.getUsername(), bookmark.getComment(),
                bookmark.getCreated(), bookmark.getChanged());
        int id = queryForInt("select id from bookmark where media_file_id=? and username=?", 0, bookmark.getMediaFileId(), bookmark.getUsername());
        bookmark.setId(id);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:16,代码来源:BookmarkDao.java

示例5: createBookmark

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
public void createBookmark(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    String username = securityService.getCurrentUsername(request);
    int mediaFileId = getRequiredIntParameter(request, "id");
    long position = getRequiredLongParameter(request, "position");
    String comment = request.getParameter("comment");
    Date now = new Date();

    Bookmark bookmark = new Bookmark(0, mediaFileId, position, username, comment, now, now);
    bookmarkDao.createOrUpdateBookmark(bookmark);
    refreshBookmarkCache();
    XMLBuilder builder = createXMLBuilder(request, response, true).endAll();
    response.getWriter().print(builder);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:15,代码来源:RESTController.java

示例6: createAttributesForBookmark

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
private List<Attribute> createAttributesForBookmark(Bookmark bookmark) {
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new Attribute("position", bookmark.getPositionMillis()));
    attributes.add(new Attribute("username", bookmark.getUsername()));
    attributes.add(new Attribute("comment", bookmark.getComment()));
    attributes.add(new Attribute("created", StringUtil.toISO8601(bookmark.getCreated())));
    attributes.add(new Attribute("changed", StringUtil.toISO8601(bookmark.getChanged())));
    return attributes;
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:10,代码来源:RESTController.java

示例7: refreshBookmarkCache

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
private void refreshBookmarkCache() {
    bookmarkCache.clear();
    for (Bookmark bookmark : bookmarkDao.getBookmarks()) {
        bookmarkCache.put(BookmarkKey.forBookmark(bookmark), bookmark);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:7,代码来源:RESTController.java

示例8: createJaxbChild

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
private <T extends Child> T createJaxbChild(T child, Player player, MediaFile mediaFile, String username) {
    MediaFile parent = mediaFileService.getParentOf(mediaFile);
    child.setId(String.valueOf(mediaFile.getId()));
    try {
        if (!mediaFileService.isRoot(parent)) {
            child.setParent(String.valueOf(parent.getId()));
        }
    } catch (SecurityException x) {
        // Ignored.
    }
    child.setTitle(mediaFile.getName());
    child.setAlbum(mediaFile.getAlbumName());
    child.setArtist(mediaFile.getArtist());
    child.setIsDir(mediaFile.isDirectory());
    child.setCoverArt(findCoverArt(mediaFile, parent));
    child.setYear(mediaFile.getYear());
    child.setGenre(mediaFile.getGenre());
    child.setCreated(jaxbWriter.convertDate(mediaFile.getCreated()));
    child.setStarred(jaxbWriter.convertDate(mediaFileDao.getMediaFileStarredDate(mediaFile.getId(), username)));
    child.setUserRating(ratingService.getRatingForUser(username, mediaFile));
    child.setAverageRating(ratingService.getAverageRating(mediaFile));

    if (mediaFile.isFile()) {
        child.setDuration(mediaFile.getDurationSeconds());
        child.setBitRate(mediaFile.getBitRate());
        child.setTrack(mediaFile.getTrackNumber());
        child.setDiscNumber(mediaFile.getDiscNumber());
        child.setSize(mediaFile.getFileSize());
        String suffix = mediaFile.getFormat();
        child.setSuffix(suffix);
        child.setContentType(StringUtil.getMimeType(suffix));
        child.setIsVideo(mediaFile.isVideo());
        child.setPath(getRelativePath(mediaFile));

        Bookmark bookmark = bookmarkCache.get(new BookmarkKey(username, mediaFile.getId()));
        if (bookmark != null) {
            child.setBookmarkPosition(bookmark.getPositionMillis());
        }

        if (mediaFile.getAlbumArtist() != null && mediaFile.getAlbumName() != null) {
            Album album = albumDao.getAlbum(mediaFile.getAlbumArtist(), mediaFile.getAlbumName());
            if (album != null) {
                child.setAlbumId(String.valueOf(album.getId()));
            }
        }
        if (mediaFile.getArtist() != null) {
            Artist artist = artistDao.getArtist(mediaFile.getArtist());
            if (artist != null) {
                child.setArtistId(String.valueOf(artist.getId()));
            }
        }
        switch (mediaFile.getMediaType()) {
            case MUSIC:
                child.setType(MediaType.MUSIC);
                break;
            case PODCAST:
                child.setType(MediaType.PODCAST);
                break;
            case AUDIOBOOK:
                child.setType(MediaType.AUDIOBOOK);
                break;
            case VIDEO:
                child.setType(MediaType.VIDEO);
                child.setOriginalWidth(mediaFile.getWidth());
                child.setOriginalHeight(mediaFile.getHeight());
                break;
            default:
                break;
        }

        if (transcodingService.isTranscodingRequired(mediaFile, player)) {
            String transcodedSuffix = transcodingService.getSuffix(player, mediaFile, null);
            child.setTranscodedSuffix(transcodedSuffix);
            child.setTranscodedContentType(StringUtil.getMimeType(transcodedSuffix));
        }
    }
    return child;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:79,代码来源:RESTController.java

示例9: forBookmark

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
static BookmarkKey forBookmark(Bookmark b) {
    return new BookmarkKey(b.getUsername(), b.getMediaFileId());
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:4,代码来源:RESTController.java

示例10: mapRow

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
public Bookmark mapRow(ResultSet rs, int rowNum) throws SQLException {
    return new Bookmark(rs.getInt(1), rs.getInt(2), rs.getLong(3), rs.getString(4),
            rs.getString(5), rs.getTimestamp(6), rs.getTimestamp(7));
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:5,代码来源:BookmarkDao.java

示例11: getBookmarks

import net.sourceforge.subsonic.domain.Bookmark; //导入依赖的package包/类
/**
 * Returns all bookmarks.
 *
 * @return Possibly empty list of all bookmarks.
 */
public List<Bookmark> getBookmarks() {
    String sql = "select " + COLUMNS + " from bookmark";
    return query(sql, bookmarkRowMapper);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:10,代码来源:BookmarkDao.java


注:本文中的net.sourceforge.subsonic.domain.Bookmark类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。