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


Java ContentDirectoryException类代码示例

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


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

示例1: search

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId,
                           String searchCriteria, String filter,
                           long firstResult, long maxResults,
                           SortCriterion[] orderBy) throws ContentDirectoryException {
    // i don't see a parser for upnp search criteria anywhere, so this will
    // have to do
    String upnpClass = searchCriteria.replaceAll("^.*upnp:class\\s+[\\S]+\\s+\"([\\S]*)\".*$", "$1");
    String titleSearch = searchCriteria.replaceAll("^.*dc:title\\s+[\\S]+\\s+\"([\\S]*)\".*$", "$1");
    BrowseResult returnValue = null;
    if ("object.container.person.musicArtist".equalsIgnoreCase(upnpClass)) {
        returnValue = getArtistProcessor().searchByName(titleSearch, firstResult, maxResults, orderBy);
    } else if ("object.item.audioItem".equalsIgnoreCase(upnpClass)) {
        returnValue = getMediaFileProcessor().searchByName(titleSearch, firstResult, maxResults, orderBy);
    } else if ("object.container.album.musicAlbum".equalsIgnoreCase(upnpClass)) {
        returnValue = getAlbumProcessor().searchByName(titleSearch, firstResult, maxResults, orderBy);
    }

    return returnValue != null ? returnValue : super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:21,代码来源:DispatchingContentDirectory.java

示例2: searchByName

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
public BrowseResult searchByName(String name,
                                 long firstResult, long maxResults,
                                 SortCriterion[] orderBy)
    throws ContentDirectoryException {
    DIDLContent didl = new DIDLContent();

    Class clazz =  (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];

    try {
        List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();
        ParamSearchResult<T> result = getDispatcher().getSearchService().searchByName(name, (int) firstResult, (int) maxResults, allFolders, clazz);
        List<T> selectedItems = result.getItems();
        for (T item : selectedItems) {
            addItem(didl, item);
        }

        return createBrowseResult(didl, (int) didl.getCount(), result.getTotalHits());
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:22,代码来源:UpnpContentProcessor.java

示例3: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {
    String address = Utils.getIPAddress(true);
    String serverUrl = "http://" + address + ":" + JettyResourceServer.JETTY_SERVER_PORT;

    //Create container by id
    Container resultBean = ContainerFactory.createContainer(objectID, serverUrl);
    DIDLContent content = new DIDLContent();

    for (Container c : resultBean.getContainers())
        content.addContainer(c);

    for (Item item : resultBean.getItems())
        content.addItem(item);

    int count = resultBean.getChildCount();
    String contentModel = "";
    try {
        contentModel = new DIDLParser().generate(content);
    } catch (Exception e) {
        throw new ContentDirectoryException(
                ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString());
    }

    return new BrowseResult(contentModel, count, count);
}
 
开发者ID:kevinshine,项目名称:BeyondUPnP,代码行数:27,代码来源:BeyondContentDirectoryService.java

示例4: search

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId,
                           String searchCriteria, String filter,
                           long firstResult, long maxResults,
                           SortCriterion[] orderBy) throws ContentDirectoryException {
    // You can override this method to implement searching!
    return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:9,代码来源:CustomContentDirectory.java

示例5: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag, String filter, long firstResult,
        long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {

    LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter +
            ", firstResult: " + firstResult + ", maxResults: " + maxResults);

    // maxResult == 0 means all.
    if (maxResults == 0) {
        maxResults = Integer.MAX_VALUE;
    }

    try {
        if (CONTAINER_ID_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browseRootMetadata() : browseRoot(firstResult, maxResults);
        }
        if (CONTAINER_ID_PLAYLIST_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistRootMetadata() : browsePlaylistRoot(firstResult, maxResults);
        }
        if (objectId.startsWith(CONTAINER_ID_PLAYLIST_PREFIX)) {
            int playlistId = Integer.parseInt(objectId.replace(CONTAINER_ID_PLAYLIST_PREFIX, ""));
            Playlist playlist = playlistService.getPlaylist(playlistId);
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistMetadata(playlist) : browsePlaylist(playlist, firstResult, maxResults);
        }

        int mediaFileId = Integer.parseInt(objectId.replace(CONTAINER_ID_FOLDER_PREFIX, ""));
        MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
        return browseFlag == BrowseFlag.METADATA ? browseMediaFileMetadata(mediaFile) : browseMediaFile(mediaFile, firstResult, maxResults);

    } catch (Throwable x) {
        LOG.error("UPnP error: " + x, x);
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString());
    }
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:35,代码来源:FolderBasedContentDirectory.java

示例6: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag, String filter, long firstResult,
        long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {

    if (!settingsService.getLicenseInfo().isLicenseOrTrialValid()) {
        LOG.warn("UPnP/DLNA media server not available. Please upgrade to Subsonic Premium.");
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, "Please upgrade to Subsonic Premium");
    }

    LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter +
            ", firstResult: " + firstResult + ", maxResults: " + maxResults);

    // maxResult == 0 means all.
    if (maxResults == 0) {
        maxResults = Integer.MAX_VALUE;
    }

    try {
        if (CONTAINER_ID_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browseRootMetadata() : browseRoot(firstResult, maxResults);
        }
        if (CONTAINER_ID_PLAYLIST_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistRootMetadata() : browsePlaylistRoot(firstResult, maxResults);
        }
        if (objectId.startsWith(CONTAINER_ID_PLAYLIST_PREFIX)) {
            int playlistId = Integer.parseInt(objectId.replace(CONTAINER_ID_PLAYLIST_PREFIX, ""));
            Playlist playlist = playlistService.getPlaylist(playlistId);
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistMetadata(playlist) : browsePlaylist(playlist, firstResult, maxResults);
        }

        int mediaFileId = Integer.parseInt(objectId.replace(CONTAINER_ID_FOLDER_PREFIX, ""));
        MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
        return browseFlag == BrowseFlag.METADATA ? browseMediaFileMetadata(mediaFile) : browseMediaFile(mediaFile, firstResult, maxResults);

    } catch (Throwable x) {
        LOG.error("UPnP error: " + x, x);
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString());
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:40,代码来源:FolderBasedContentDirectory.java

示例7: search

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId, String searchCriteria,
		String filter, long firstResult, long maxResults,
		SortCriterion[] orderBy) throws ContentDirectoryException {
	// TODO Auto-generated method stub
	Log.e(LOG_TAG, "containerId:" + containerId + ",searchCriteria:"
			+ searchCriteria + ",filter:" + filter + ",firstResult:"
			+ firstResult + ",maxResults:" + maxResults + ",orderBy:"
			+ orderBy);
	return super.search(containerId, searchCriteria, filter, firstResult,
			maxResults, orderBy);
}
 
开发者ID:sky24987,项目名称:UPlayer,代码行数:13,代码来源:ContentDirectoryService.java

示例8: search

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId, String searchCriteria,
		String filter, long firstResult, long maxResults,
		SortCriterion[] orderBy) throws ContentDirectoryException {
	// You can override this method to implement searching!
	return super.search(containerId, searchCriteria, filter, firstResult,
			maxResults, orderBy);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:9,代码来源:ContentDirectoryService.java

示例9: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag, String filter, long firstResult,
        long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {

    if (!settingsService.getLicenseInfo().isLicenseOrTrialValid()) {
        LOG.warn("UPnP/DLNA media server not available. Please upgrade to Subsonic Premium.");
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, "Please upgrade to Subsonic Premium");
    }

    LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter +
            ", firstResult: " + firstResult + ", maxResults: " + maxResults);

    // maxResult == 0 means all.
    if (maxResults == 0) {
        maxResults = Integer.MAX_VALUE;
    }

    try {
        if (CONTAINER_ID_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browseRootMetadata() : browseRoot(firstResult, maxResults);
        }
        if (CONTAINER_ID_PLAYLIST_ROOT.equals(objectId)) {
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistRootMetadata() : browsePlaylistRoot(firstResult, maxResults);
        }
        if (objectId.startsWith(CONTAINER_ID_PLAYLIST_PREFIX)) {
            int playlistId = Integer.parseInt(objectId.replace(CONTAINER_ID_PLAYLIST_PREFIX, ""));
            Playlist playlist = playlistService.getPlaylist(playlistId);
            return browseFlag == BrowseFlag.METADATA ? browsePlaylistMetadata(playlist) : browsePlaylist(playlist, firstResult, maxResults);
        }

        MediaFile mediaFile = mediaFileService.getMediaFile(Integer.parseInt(objectId));
        return browseFlag == BrowseFlag.METADATA ? browseMediaFileMetadata(mediaFile) : browseMediaFile(mediaFile, firstResult, maxResults);

    } catch (Throwable x) {
        LOG.error("UPnP error: " + x, x);
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString());
    }
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:39,代码来源:FolderBasedContentDirectory.java

示例10: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag,
                           String filter, long firstResult,
                           long maxResults, SortCriterion[] orderBy)
    throws ContentDirectoryException {

    LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter + ", firstResult: " + firstResult + ", maxResults: " + maxResults);

    if (objectId == null)
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, "objectId is null");

    // maxResult == 0 means all.
    if (maxResults == 0) {
        maxResults = Long.MAX_VALUE;
    }

    BrowseResult returnValue = null;
    try {
        String[] splitId = objectId.split(SEPARATOR);
        String browseRoot = splitId[0];
        String itemId = splitId.length == 1 ? null : splitId[1];

        UpnpContentProcessor processor = findProcessor(browseRoot);
        if (processor == null) {
            // if it's null then assume it's a file, and that the id
            // is all that's there.
            itemId = browseRoot;
            processor = getMediaFileProcessor();
        }

        if (itemId == null) {
            returnValue = browseFlag == BrowseFlag.METADATA ? processor.browseRootMetadata() : processor.browseRoot(filter, firstResult, maxResults, orderBy);
        } else {
            returnValue = browseFlag == BrowseFlag.METADATA ? processor.browseObjectMetadata(itemId) : processor.browseObject(itemId, filter, firstResult, maxResults, orderBy);
        }
        return returnValue;
    } catch (Throwable x) {
        LOG.error("UPnP error: " + x, x);
        throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString());
    }
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:42,代码来源:DispatchingContentDirectory.java

示例11: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag, String s1, long l, long l1,
                           SortCriterion[] sortCriterions) throws ContentDirectoryException {
    try {

        DIDLContent didl = new DIDLContent();

        ContentNode contentNode = ContentTree.getNode(objectID);

        Log.d(TAG, "someone's browsing id: " + objectID);

        if (contentNode == null) { // 没有共享资源
            return new BrowseResult("", 0, 0);
        }

        if (contentNode.isItem()) { // 是文件
            didl.addItem(contentNode.getItem());

            Log.v(TAG, "returing item: " + contentNode.getItem().getTitle());

            return new BrowseResult(new DIDLParser().generate(didl), 1, 1);

        } else { // 是文件夹
            if (browseFlag == BrowseFlag.METADATA) {
                didl.addContainer(contentNode.getContainer());

                Log.v(TAG, "returning metadata of container: " + contentNode.getContainer().getTitle());

                return new BrowseResult(new DIDLParser().generate(didl), 1, 1);

            } else {
                for (Container container : contentNode.getContainer().getContainers()) {
                    didl.addContainer(container);

                    Log.v(TAG, "getting child container: " + container.getTitle());
                }
                for (Item item : contentNode.getContainer().getItems()) {
                    didl.addItem(item);

                    Log.v(TAG, "getting child item: " + item.getTitle());
                }
                return new BrowseResult(new DIDLParser().generate(didl),
                        contentNode.getContainer().getChildCount(),
                        contentNode.getContainer().getChildCount());
            }

        }

    } catch (Exception e) {
        throw new ContentDirectoryException(
                ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString());
    }
}
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:54,代码来源:ContentDirectoryService.java

示例12: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectId, BrowseFlag browseFlag,
		String filter, long firstResult, long maxResult,
		SortCriterion[] sortCriterion) throws ContentDirectoryException {
	// TODO Auto-generated method stub
	try {
		DIDLContent content = new DIDLContent();
		ContentNode node = ContentTree.getContentNode(objectId, true);
		Log.i(LOG_TAG, "The browse object id is:" + objectId);
		if (node == null)
			return new BrowseResult("", 0, 0);
		if (node.isItem()) {
			content.addItem(node.getItem());
			Log.i(LOG_TAG, "Get the item:" + node.getItem().getTitle());
			return new BrowseResult(new DIDLParser().generate(content), 1,
					1);
		} else {
			if (browseFlag == BrowseFlag.METADATA) {
				content.addContainer(node.getContainer());
				Log.i(LOG_TAG, "Get meta data of container:"
						+ node.getContainer().getTitle());
				return new BrowseResult(new DIDLParser().generate(content),
						1, 1);
			} else {
				for (Container container : node.getContainer()
						.getContainers()) {
					content.addContainer(container);
					Log.i(LOG_TAG,
							"Get child container:" + container.getTitle());
				}
				for (Item item : node.getContainer().getItems()) {
					content.addItem(item);
					Log.i(LOG_TAG, "Get child item:" + item.getTitle());
				}
				return new BrowseResult(new DIDLParser().generate(content),
						node.getContainer().getChildCount(), node
								.getContainer().getChildCount());
			}
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		Log.e(LOG_TAG, "Generate browse result failed!");
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:sky24987,项目名称:UPlayer,代码行数:47,代码来源:ContentDirectoryService.java

示例13: browse

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag,
		String filter, long firstResult, long maxResults,
		SortCriterion[] orderby) throws ContentDirectoryException {
	// TODO Auto-generated method stub
	try {

		DIDLContent didl = new DIDLContent();

		ContentNode contentNode = ContentTree.getNode(objectID);
		
		Log.v(LOGTAG, "someone's browsing id: " + objectID);

		if (contentNode == null)
			return new BrowseResult("", 0, 0);

		if (contentNode.isItem()) {
			didl.addItem(contentNode.getItem());
			
			Log.v(LOGTAG, "returing item: " + contentNode.getItem().getTitle());
			
			return new BrowseResult(new DIDLParser().generate(didl), 1, 1);
		} else {
			if (browseFlag == BrowseFlag.METADATA) {
				didl.addContainer(contentNode.getContainer());
				
				Log.v(LOGTAG, "returning metadata of container: " + contentNode.getContainer().getTitle());
				
				return new BrowseResult(new DIDLParser().generate(didl), 1,
						1);
			} else {
				for (Container container : contentNode.getContainer()
						.getContainers()) {
					didl.addContainer(container);
					
					Log.v(LOGTAG, "getting child container: " + container.getTitle());
				}
				for (Item item : contentNode.getContainer().getItems()) {
					didl.addItem(item);
					
					Log.v(LOGTAG, "getting child item: " + item.getTitle());
				}
				return new BrowseResult(new DIDLParser().generate(didl),
						contentNode.getContainer().getChildCount(),
						contentNode.getContainer().getChildCount());
			}

		}

	} catch (Exception ex) {
		throw new ContentDirectoryException(
				ContentDirectoryErrorCode.CANNOT_PROCESS, ex.toString());
	}
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:55,代码来源:ContentDirectoryService.java

示例14: search

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Override
public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy)
    throws ContentDirectoryException {
  // You can override this method to implement searching!
  return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy);
}
 
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:7,代码来源:ContentDirectoryService.java

示例15: browseRoot

import org.fourthline.cling.support.contentdirectory.ContentDirectoryException; //导入依赖的package包/类
@Test
public void browseRoot() throws ContentDirectoryException {
  browse("0", BrowseFlag.DIRECT_CHILDREN);
}
 
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:5,代码来源:ContentDirectoryBrowseTest.java


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