cbr.service
Class URLPicsSource

java.lang.Object
  extended byde.fhg.igd.semoa.service.AbstractService
      extended bycbr.service.URLPicsSource
All Implemented Interfaces:
PicsSource, Service

public class URLPicsSource
extends AbstractService
implements PicsSource

A class which implements the service that is used to advertise pictures loaded remotely from a base URL.

This class provides an iterator for the pictures in the configured picture directory. This iterator attempts to open and read line by line a file with the name " ls.txt" relative to the base URL of this plugin. This file must contain the names of the known pictures. Such a file can be created simply by issuing the command ls >ls.txt in the picture directory.

Iterating through the picture names and loading pictures requires that this class has privileges to access the network. Malicious code can not create an instance of this class and exploit it to access the network.

Version:
"$Id: URLPicsSource.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth
See Also:
PrivilegedOpen, Service

Field Summary
static int BUFFER_SIZE
          The size of the buffer that is used to load images.
protected  URL pictures_
          The URL from which pictures are loaded.
protected  URL thumbnails_
          The URL from which thumbnails are loaded.
private  boolean warned_
          A flag that surpresses multiple warnings.
 
Fields inherited from class de.fhg.igd.semoa.service.AbstractService
REV_POSTFIX, REV_PREFIX
 
Constructor Summary
URLPicsSource()
          Creates an instance to be registered on the given level using the given name.
URLPicsSource(URL p, URL t)
          Creates an instance which loads images from the given URLs.
 
Method Summary
 String author()
          Returns the name of the author of the service.
 byte[] getPicture(String name)
          Retrieves a picture based on the name.
 byte[] getThumbnail(String name)
          Retrieves a thumbnail based on the name.
 String info()
          Returns the informative string which should describe the service's essence in a sentence.
 Iterator iterator()
          Returns an iterator that iterates the names of the available pictures.
private  byte[] loadPicture(URL url)
          Loads a file into a byte array.
 String revision()
          Returns the revision number of this class as a string.
 void setPictures(String url)
           
 void setThumbnails(String url)
           
private  void warn()
           
 
Methods inherited from class de.fhg.igd.semoa.service.AbstractService
checkDependencies, dependencies, docs, doPrivileged, doPrivileged, getACC, getEnvironment, majorVersion, minorVersion, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
The size of the buffer that is used to load images.

See Also:
Constant Field Values

pictures_

protected URL pictures_
The URL from which pictures are loaded.


thumbnails_

protected URL thumbnails_
The URL from which thumbnails are loaded.


warned_

private volatile boolean warned_
A flag that surpresses multiple warnings.

Constructor Detail

URLPicsSource

public URLPicsSource()
Creates an instance to be registered on the given level using the given name.


URLPicsSource

public URLPicsSource(URL p,
                     URL t)
Creates an instance which loads images from the given URLs. For each image there should be a thumbnail available. Thumbnails must have the same name as the picture they refer to.

Parameters:
p - The URL containing the available pictures.
t - The URL containing the thumbnails for the available pictures.
Method Detail

setPictures

public void setPictures(String url)
                 throws MalformedURLException
Throws:
MalformedURLException

setThumbnails

public void setThumbnails(String url)
                   throws MalformedURLException
Throws:
MalformedURLException

author

public String author()
Description copied from class: AbstractService
Returns the name of the author of the service. The format to be used should be John Doe <jdoe@zilch.net>.

Specified by:
author in interface Service
Specified by:
author in class AbstractService
Returns:
the String with the author's name.

revision

public String revision()
Description copied from class: AbstractService
Returns the revision number of this class as a string. This class provides default implementations of methods majorVersion(), minorVersion based on the assumption that this method returns a revision string as generated by rcs(1) for the template "$Revision: 1.7 $/$Date: 2007-08-08 04:41:53 +0200 (Wed, 08 Aug 2007) $".

Specified by:
revision in class AbstractService

info

public String info()
Description copied from class: AbstractService
Returns the informative string which should describe the service's essence in a sentence.

Specified by:
info in interface Service
Specified by:
info in class AbstractService
Returns:
the String with the service's short description.

iterator

public Iterator iterator()
Returns an iterator that iterates the names of the available pictures.

The way the path is formed is unsecure. Do not use in the field.

Specified by:
iterator in interface PicsSource
Returns:
The iterator that iterates the names of the available pictures.

getPicture

public byte[] getPicture(String name)
Retrieves a picture based on the name.

The way the path is formed is unsecure. Do not use in the field.

Specified by:
getPicture in interface PicsSource
Parameters:
name - The name of the picture. This name must be locally unique.
Returns:
The encoding of the picture with the given name.

getThumbnail

public byte[] getThumbnail(String name)
Retrieves a thumbnail based on the name.

The way the path is formed is unsecure. Do not use in the field.

Specified by:
getThumbnail in interface PicsSource
Parameters:
name - The name of the picture. This name must be locally unique.
Returns:
The encoding of the picture with the given name.

loadPicture

private byte[] loadPicture(URL url)
Loads a file into a byte array. This method is used for loading pictures and thumbnails from URLs to which access is restricted.

Returns:
The bytes of the file.

warn

private void warn()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.