Methods Summary |
---|
public void | addChangeListener(ShareResourceListener l)
change_listeners.add( l );
|
public void | addDeletionListener(ShareResourceWillBeDeletedListener l)
deletion_listeners.add( l );
|
public abstract boolean | canBeDeleted()
|
protected abstract void | checkConsistency()
|
public void | delete()
if ( getParent() != null ){
throw( new ShareResourceDeletionVetoException( MessageText.getString("plugin.sharing.remove.veto")));
}
delete( false );
|
protected void | delete(boolean force)
if ( !force ){
canBeDeleted();
}
manager.delete(this);
|
protected abstract void | deleteInternal()
|
protected void | deleteTorrent(ShareItemImpl item)
manager.deleteTorrent( item );
|
public java.lang.String | getAttribute(org.gudy.azureus2.plugins.torrent.TorrentAttribute attribute)
return((String)attributes.get( attribute ));
|
public org.gudy.azureus2.plugins.torrent.TorrentAttribute[] | getAttributes()
TorrentAttribute[] res = new TorrentAttribute[attributes.size()];
attributes.keySet().toArray( res );
return( res );
|
public ShareResource[] | getChildren()
return( new ShareResource[0] );
|
protected byte[] | getFingerPrint(java.io.File file)
try{
StringBuffer buffer = new StringBuffer();
getFingerPrintSupport( buffer, file, TorrentUtils.getIgnoreSet());
return( hasher.calculateHash(buffer.toString().getBytes()));
}catch( ShareException e ){
throw( e );
}catch( Throwable e ){
throw( new ShareException( "ShareResource::getFingerPrint: fails", e ));
}
|
protected void | getFingerPrintSupport(java.lang.StringBuffer buffer, java.io.File file, java.util.Set ignore_set)
try{
if ( file.isFile()){
long mod = file.lastModified();
long size = file.length();
String file_name = file.getName();
if ( ignore_set.contains( file_name.toLowerCase())){
}else{
buffer.append( file_name ).append( ":" ).append( mod ).append( ":" ).append( size );
}
}else if ( file.isDirectory()){
File[] dir_file_list = file.listFiles();
List file_list = new ArrayList(Arrays.asList(dir_file_list));
Collections.sort(file_list);
for (int i=0;i<file_list.size();i++){
File f = (File)file_list.get(i);
String file_name = f.getName();
if ( !(file_name.equals( "." ) || file_name.equals( ".." ))){
StringBuffer sub_print = new StringBuffer();
getFingerPrintSupport( sub_print, f, ignore_set );
if ( sub_print.length() > 0 ){
buffer.append( ":" ).append( sub_print );
}
}
}
}else{
throw( new ShareException( "ShareResource::getFingetPrint: '" + file.toString() + "' doesn't exist" ));
}
}catch( Throwable e ){
if ( e instanceof ShareException ){
throw((ShareException)e);
}
Debug.printStackTrace( e );
throw( new ShareException( "ShareResource::getFingerPrint: fails", e ));
}
|
protected java.lang.String | getNewTorrentLocation()
return( manager.getNewTorrentLocation());
|
public ShareResourceDirContents | getParent()
return( parent );
|
public java.io.File | getTorrentFile(ShareItemImpl item)
return( manager.getTorrentFile(item));
|
public int | getType()
return( type );
|
protected void | inheritAttributes(org.gudy.azureus2.pluginsimpl.local.sharing.ShareResourceImpl source)
TorrentAttribute[] attrs = source.getAttributes();
for ( int i=0;i<attrs.length;i++ ){
setAttribute( attrs[i], source.getAttribute( attrs[i] ));
}
|
protected void | readTorrent(ShareItemImpl item)
manager.readTorrent( item );
|
public void | removeChangeListener(ShareResourceListener l)
change_listeners.remove( l );
|
public void | removeDeletionListener(ShareResourceWillBeDeletedListener l)
deletion_listeners.remove( l );
|
protected void | serialiseResource(java.util.Map map)
Iterator it = attributes.keySet().iterator();
Map attrs = new HashMap();
map.put( "attributes", attrs );
while( it.hasNext()){
TorrentAttribute ta = (TorrentAttribute)it.next();
String value = (String)attributes.get(ta);
try{
if ( value != null ){
attrs.put( ta.getName(), value.getBytes( Constants.DEFAULT_ENCODING ));
}
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
|
public void | setAttribute(org.gudy.azureus2.plugins.torrent.TorrentAttribute attribute, java.lang.String value)
ShareConfigImpl config = manager.getShareConfig();
try{
config.suspendSaving();
ShareResource[] kids = getChildren();
for (int i=0;i<kids.length;i++){
kids[i].setAttribute( attribute, value );
}
String old_value = (String)attributes.get( attribute );
if( old_value == null && value == null ){
return;
}
if ( old_value != null && value != null && old_value.equals( value )){
return;
}
attributes.put( attribute, value );
try{
config.saveConfig();
}catch( ShareException e ){
Debug.printStackTrace( e );
}
}finally{
try{
config.resumeSaving();
}catch( ShareException e ){
Debug.printStackTrace( e );
}
}
for (int i=0;i<change_listeners.size();i++){
try{
((ShareResourceListener)change_listeners.get(i)).shareResourceChanged(
this,
new ShareResourceEvent()
{
public int
getType()
{
return( ShareResourceEvent.ET_ATTRIBUTE_CHANGED);
}
public Object
getData()
{
return( attribute );
}
});
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
|
protected void | setParent(ShareResourceDirContents _parent)
parent = _parent;
|
protected void | writeTorrent(ShareItemImpl item)
manager.writeTorrent( item );
|