FileDocCategorySizeDatePackage
PublishUtils.javaAPI DocAzureus 3.0.3.44210Thu Aug 02 17:14:20 BST 2007com.aelitis.azureus.ui.swt.utils

PublishUtils

public class PublishUtils extends Object
Publish functions that are used by both the Publisher plugin and AZ3ui's publish window
author
TuxPaper

Fields Summary
private static final String
CONTENTMAP_KEY
private static final String
COMPLETE_ATTRIBUTE_KEY
Constructors Summary
Methods Summary
public static booleanisPublishComplete(org.gudy.azureus2.core3.download.DownloadManager dm)

		
		Map mapAttr = dm.getDownloadState().getMapAttribute(CONTENTMAP_KEY);

		if ( mapAttr == null ){
			
			return( false );
		}
		
		Long complete = (Long)mapAttr.get( COMPLETE_ATTRIBUTE_KEY );

		return( complete != null );
	
public static booleanisPublished(org.gudy.azureus2.core3.download.DownloadManager dm)

		if (dm == null) {
			return false;
		}
		try {
			Map mapAttr = dm.getDownloadState().getMapAttribute(CONTENTMAP_KEY);

			return mapAttr != null
					&& mapAttr.containsKey(PublishTransaction.PUBLISH_ATTRIBUTE_KEY);
		} catch (Exception e) {
			Debug.out("baH", e);
		}
		return false;
	
public static booleanisPublished(org.gudy.azureus2.plugins.download.Download download)

param
download
return
since
3.0.1.5

		if (download instanceof DownloadImpl) {
			return isPublished(((DownloadImpl) download).getDownload());
		}
		return false;
	
public static voidsetPublishComplete(org.gudy.azureus2.core3.download.DownloadManager dm)

		try {
			Map mapAttr = dm.getDownloadState().getMapAttribute(CONTENTMAP_KEY);

			if ( mapAttr == null ){
				
				mapAttr = new HashMap();
			}
			
			mapAttr.put( COMPLETE_ATTRIBUTE_KEY, new Long(1));
			
			dm.getDownloadState().setMapAttribute(CONTENTMAP_KEY, mapAttr);
			
		} catch (Exception e) {
			
			Debug.out("baH", e);
		}
	
public static voidsetPublished(org.gudy.azureus2.plugins.torrent.Torrent torrent)

		if (torrent instanceof TorrentImpl) {
			setPublished(((TorrentImpl) torrent).getTorrent());
		}
	
public static voidsetPublished(org.gudy.azureus2.core3.torrent.TOTorrent torrent)

param
torrent
since
3.0.1.5

		try {
			if (torrent == null) {
				return;
			}

			Map map = torrent.getAdditionalMapProperty("attributes");

			if (map != null) {
				Map mapAttr = (Map) map.get(CONTENTMAP_KEY);

				mapAttr.put(PublishTransaction.PUBLISH_ATTRIBUTE_KEY, new Long(1));
			}
		} catch (Exception e) {
			Debug.out("baH", e);
		}
	
public static voidsetPublished(org.gudy.azureus2.core3.download.DownloadManager dm, boolean isPublishedContent)

		if (isPublishedContent) {
			setPublished(dm);
			return;
		}
		
		try {
			Map mapAttr = dm.getDownloadState().getMapAttribute(CONTENTMAP_KEY);

			if (mapAttr == null) {
				return;
			}
			mapAttr = new HashMap(mapAttr);
			Object remove = mapAttr.remove(PublishTransaction.PUBLISH_ATTRIBUTE_KEY);
			if (remove != null) {
				dm.getDownloadState().setMapAttribute(CONTENTMAP_KEY, mapAttr);
			}
		} catch (Exception e) {
			Debug.out(e);
		}
	
public static voidsetPublished(org.gudy.azureus2.core3.download.DownloadManager dm)

		try {
			Map mapAttr = dm.getDownloadState().getMapAttribute(CONTENTMAP_KEY);

			if (mapAttr == null) {
				mapAttr = new HashMap();
			} else {
				mapAttr = new HashMap(mapAttr);
			}
			mapAttr.put(PublishTransaction.PUBLISH_ATTRIBUTE_KEY, new Long(1));
			dm.getDownloadState().setMapAttribute(CONTENTMAP_KEY, mapAttr);
		} catch (Exception e) {
			Debug.out("baH", e);
		}
	
public static voidsetPublished(org.gudy.azureus2.plugins.download.Download download)

		if (download instanceof DownloadImpl) {
			setPublished(((DownloadImpl) download).getDownload());
		}
	
public static voidsetupContext(com.aelitis.azureus.core.messenger.ClientMessageContext context)


	     
		context.registerTransactionType("publish", PublishTransaction.class);
		context.addMessageListener(new SeedingListener());