* Represents a television program.
*/
public class Program {
-
+
/**
- * Lexicographical comparison of programs based on (time, title, channel).
- *
+ * Lexicographical comparison of programs based on (time, title, channel).
+ *
*/
- public static class TimeSorter implements Comparator<Program> {
-
- /* (non-Javadoc)
- * @see java.util.Comparator#compare(T, T)
+ public static class TimeSorter implements Comparator<Program> {
+
+ /**
+ * Lexicographical comparison based on start time, program name, and
+ * channel.
+ *
+ * @param aProgram1
+ * First program.
+ * @param aProgram2
+ * Second program.
+ * @return See {@link Comparator#compare(T, T)}
*/
- public int compare(Program o1, Program o2) {
- int value = o1.getInterval().getBegin().compareTo(o2.getInterval().getBegin());
- if ( value != 0 ) {
- return value;
+ public int compare(Program aProgram1, Program aProgram2) {
+ int value = aProgram1.getInterval().getBegin().compareTo(
+ aProgram2.getInterval().getBegin());
+ if (value != 0) {
+ return value;
}
- value = o1.getName().compareTo(o2.getName());
- if (value != 0 ) {
- return value;
+ value = aProgram1.getName().compareTo(aProgram2.getName());
+ if (value != 0) {
+ return value;
}
- return o1.getChannel().compareTo(o2.getChannel());
+ return aProgram1.getChannel().compareTo(aProgram2.getChannel());
}
}
-
+
private static final Log LOG = LogFactory.getLog(Program.class);
/**
private static final String RESULT_ELEM = "result";
+ /**
+ * Result of recording a program.
+ *
+ */
public enum RecordingResult {
- OK("Successfully recorded programs"), DUPLICATE(
- "Already recorded programs"), CONFLICT(
- "Programs in conflict with another recorded program"), OLDSHOW(
- "Programs that occurred in the past"), ERROR(
- "Programs that could not be recorded for technical reasons");
+ /**
+ * Successfully recorded.
+ */
+ OK("Successfully recorded programs"),
+
+ /**
+ * Already recorded program.
+ */
+ DUPLICATE("Already recorded programs"),
+
+ /**
+ * Recording conflict with another program.
+ */
+ CONFLICT("Programs in conflict with another recorded program"),
+
+ /**
+ * Program occurred in the past.
+ */
+ OLDSHOW("Programs that occurred in the past"),
+
+ /**
+ * Program could not be recorded for technical reasons.
+ */
+ ERROR("Programs that could not be recorded for technical reasons");
private String _description;
_description = aDescription;
}
+ /**
+ * Gets the description.
+ * @return Description.
+ */
public String getDescription() {
return _description;
}
public TimeInterval getInterval() {
return _interval;
}
-
+
/**
- * Checks if recording is possible.
- * @return True iff recording is possible.
+ * Checks if recording is possible.
+ *
+ * @return True iff recording is possible.
*/
- public boolean isRecordingPossible() {
+ public boolean isRecordingPossible() {
try {
Action record = _programInfo.execute().getAction(RECORD_ACTION);
if (record == null) {
- return false;
+ return false;
}
- return true;
+ return true;
} catch (PageException e) {
- return false;
+ return false;
}
}
*/
public RecordingResult record() {
LOG.info("Recording " + this);
- if ( SystemProperties.isRecordDisabled() ) {
+ if (SystemProperties.isRecordDisabled()) {
return RecordingResult.OK;
}
try {
return RecordingResult.OLDSHOW;
}
Page result = record.execute();
- RecordingResult recordingResult = RecordingResult.valueOf(result.getContent().getText());
+ RecordingResult recordingResult = RecordingResult.valueOf(result
+ .getContent().getText());
LOG.info(" result: " + recordingResult);
return recordingResult;
} catch (PageException e) {
+ ")" + "\n"
+ (INDENT + _description).replaceAll("\n", "\n" + INDENT);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
- if ( !(obj instanceof Program)) {
- return false;
+ public boolean equals(Object aObject) {
+ if (!(aObject instanceof Program)) {
+ return false;
}
- Program program = (Program)obj;
- return getName().equals(program.getName()) &&
- _programInfo.equals(program._programInfo);
+ Program program = (Program) aObject;
+ return getName().equals(program.getName())
+ && _programInfo.equals(program._programInfo);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return getName().hashCode();
}
-
+
/**
- * Converts program information to XML.
- * @return XML representation of program information.
+ * Converts program information to XML.
+ *
+ * @return XML representation of program information.
*/
- public Element asXml() {
+ public Element asXml() {
DocumentFactory factory = DocumentFactory.getInstance();
- Element program = factory.createElement("program");
+ Element program = factory.createElement("program");
program.addElement("name").setText(getName());
program.addElement("description").setText(getDescription());
program.addElement("keywords").setText(getKeywords());
program.addElement("channel").setText(getChannel());
Element interval = program.addElement("interval");
- interval.addElement("begin").setText(getInterval().getBegin().toString());
+ interval.addElement("begin").setText(
+ getInterval().getBegin().toString());
interval.addElement("end").setText(getInterval().getEnd().toString());
- return program;
+ return program;
}
}
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
- if ( !(obj instanceof Time )) {
- return false;
+ public boolean equals(Object aObject) {
+ if (!(aObject instanceof Time)) {
+ return false;
}
- return toString().equals(obj.toString());
+ return toString().equals(aObject.toString());
}
-
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(T)
+
+ /**
+ * Compares based on time.
+ * @param aObject Time object to compare to.
+ * @return See {@link Comparable#compareTo(T)}.
*/
- public int compareTo(Object o) {
- if ( !(o instanceof Time)) {
- throw new RuntimeException("object not an instance of Time");
+ public int compareTo(Object aObject) {
+ if (!(aObject instanceof Time)) {
+ throw new RuntimeException("object not an instance of Time");
}
- Time time = (Time)o;
+ Time time = (Time) aObject;
return new Float(asFloat()).compareTo(new Float(time.asFloat()));
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
@Override
package org.wamblee.crawler.kiss.guide;
-
/**
- * Time interval.
+ * Time interval.
*/
public class TimeInterval {
/**
- * Begin time.
+ * Begin time.
*/
private Time _begin;
/**
- * End time.
+ * End time.
*/
private Time _end;
/**
- * Construts the interval.
- * @param aBegin Start time.
- * @param aEnd End time.
+ * Construts the interval.
+ *
+ * @param aBegin
+ * Start time.
+ * @param aEnd
+ * End time.
*/
public TimeInterval(Time aBegin, Time aEnd) {
_begin = aBegin;
}
/**
- * Gets the begin time.
- * @return Begin time.
+ * Gets the begin time.
+ *
+ * @return Begin time.
*/
public Time getBegin() {
return _begin;
}
/**
- * Gets the end time.
- * @return End time.
+ * Gets the end time.
+ *
+ * @return End time.
*/
public Time getEnd() {
return _end;
boolean isUncertain() {
return _begin.asFloat() > _end.asFloat();
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)j
*/
@Override
- public boolean equals(Object obj) {
- if ( !(obj instanceof TimeInterval)) {
- return false;
- }
- return obj.toString().equals(obj.toString());
+ public boolean equals(Object aObject) {
+ if (!(aObject instanceof TimeInterval)) {
+ return false;
+ }
+ return aObject.toString().equals(aObject.toString());
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
@Override
try {
HttpClient client = new HttpClient();
- //client.getHostConfiguration().setProxy("127.0.0.1", 3128);
+ // client.getHostConfiguration().setProxy("127.0.0.1", 3128);
Crawler crawler = createCrawler(aCrawlerConfig, os, client);
InputStream programConfigFile = new FileInputStream(new File(
aProgramConfig));
ProgramConfigurationParser parser = new ProgramConfigurationParser();
parser.parse(programConfigFile);
- List<ProgramFilter> programFilters = parser.getFilters();
-
+ List<ProgramFilter> programFilters = parser.getFilters();
+
Page page = getStartPage(aStartUrl, crawler);
TVGuide guide = createGuide(page);
PrintVisitor printer = new PrintVisitor(System.out);
executor.commit();
try {
aNotifier.send(executor.getReport());
- } catch (NotificationException e) {
+ } catch (NotificationException e) {
throw new RuntimeException(e);
}
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.crawler.kiss.main;
import org.wamblee.crawler.kiss.guide.Program;
/**
- * Represents an action configured for a program.
+ * Represents an action configured for a program.
*/
public interface ProgramAction {
/**
- * Executes the action.
- * @param aProgram Program to execute the action for.
- * @param aExecutor Report to use.
+ * Executes the action.
+ *
+ * @param aProgram
+ * Program to execute the action for.
+ * @param aExecutor
+ * Report to use.
*/
void execute(Program aProgram, ProgramActionExecutor aExecutor);
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.crawler.kiss.main;
import org.wamblee.crawler.kiss.guide.Program.RecordingResult;
/**
- * Provides execution of actions for programs. Actions use
- * this class to tell the executor what to do. The executor then decide
- * on exactly what to do and in what order and makes decisions in case
- * of conflicts.
+ * Provides execution of actions for programs. Actions use this class to tell
+ * the executor what to do. The executor then decide on exactly what to do and
+ * in what order and makes decisions in case of conflicts.
*/
public class ProgramActionExecutor {
-
+
/**
- * A map of category name to a set of program. Useful for displaying the output of
- * possibly interesting programs on a per category basis.
+ * A map of category name to a set of program. Useful for displaying the
+ * output of possibly interesting programs on a per category basis.
*/
private Map<String, Set<Program>> _interestingShows;
-
+
/**
- * Set of programs to record.
+ * Set of programs to record.
*/
private Set<Program> _showsToRecord;
-
+
/**
- * Map or recording result to a set of programs.
+ * Map or recording result to a set of programs.
*/
private EnumMap<RecordingResult, Set<Program>> _recordings;
-
+
/**
- * Constructs the program action executor.
- *
+ * Constructs the program action executor.
+ *
*/
- public ProgramActionExecutor() {
- _interestingShows = new TreeMap<String,Set<Program>>();
+ public ProgramActionExecutor() {
+ _interestingShows = new TreeMap<String, Set<Program>>();
_showsToRecord = new TreeSet<Program>(new Program.TimeSorter());
_recordings = new EnumMap<RecordingResult, Set<Program>>(
RecordingResult.class);
for (RecordingResult result : RecordingResult.values()) {
- _recordings.put(result, new TreeSet<Program>(new Program.TimeSorter()));
+ _recordings.put(result, new TreeSet<Program>(
+ new Program.TimeSorter()));
}
}
-
+
/**
* Called by an action to indicate the desire to record a program.
- * @param aPriority Priority of the program. Used to resolve conflicts.
- * @param aProgram Program to record.
+ *
+ * @param aPriority
+ * Priority of the program. Used to resolve conflicts.
+ * @param aProgram
+ * Program to record.
*/
- public void recordProgram(int aPriority, Program aProgram) {
+ public void recordProgram(int aPriority, Program aProgram) {
_showsToRecord.add(aProgram);
}
-
+
/**
- * Called by an action to indicate that a program is interesting.
- * @param aCategory Category of the program.
- * @param aProgram Program.
+ * Called by an action to indicate that a program is interesting.
+ *
+ * @param aCategory
+ * Category of the program.
+ * @param aProgram
+ * Program.
*/
- public void interestingProgram(String aCategory, Program aProgram) {
- Set<Program> programs = _interestingShows.get(aCategory);
- if ( programs == null ) {
+ public void interestingProgram(String aCategory, Program aProgram) {
+ Set<Program> programs = _interestingShows.get(aCategory);
+ if (programs == null) {
programs = new TreeSet<Program>(new Program.TimeSorter());
_interestingShows.put(aCategory, programs);
}
programs.add(aProgram);
}
-
+
/**
* Makes sure that the actions are performed.
- *
+ *
*/
- public void commit() {
- for (Program program: _showsToRecord) {
- RecordingResult result = program.record();
+ public void commit() {
+ for (Program program : _showsToRecord) {
+ RecordingResult result = program.record();
_recordings.get(result).add(program);
}
}
-
+
/**
- * Get report as XML.
- * @return XML report
+ * Get report as XML.
+ *
+ * @return XML report
*/
- public Element getReport() {
- DocumentFactory factory = DocumentFactory.getInstance();
- Element report = factory.createElement("report");
-
+ public Element getReport() {
+ DocumentFactory factory = DocumentFactory.getInstance();
+ Element report = factory.createElement("report");
+
for (RecordingResult result : RecordingResult.values()) {
if (_recordings.get(result).size() > 0) {
- Element recordingResult = report.addElement("recorded").addAttribute("result", result.toString());
-
+ Element recordingResult = report.addElement("recorded")
+ .addAttribute("result", result.toString());
+
for (Program program : _recordings.get(result)) {
- recordingResult.add(program.asXml());
+ recordingResult.add(program.asXml());
}
}
}
-
-
- if ( _interestingShows.size() > 0 ) {
+
+ if (_interestingShows.size() > 0) {
Element interesting = report.addElement("interesting");
- for (String category: _interestingShows.keySet()) {
- Element categoryElem = interesting;
- if ( category.length() > 0 ) {
+ for (String category : _interestingShows.keySet()) {
+ Element categoryElem = interesting;
+ if (category.length() > 0) {
categoryElem = interesting.addElement("category");
categoryElem.addAttribute("name", category);
}
- for (Program program: _interestingShows.get(category)) {
- categoryElem.add(program.asXml());
+ for (Program program : _interestingShows.get(category)) {
+ categoryElem.add(program.asXml());
}
}
-
+
}
-
- return report;
+
+ return report;
}
}
*/
class ProgramConfigurationParser {
+ /**
+ *
+ */
+ private static final int DEFAULT_SMTP_PORT = 25;
+
private static final String ELEM_PASSWORD = "password";
private static final String ELEM_USERNAME = "username";
// Formatting configuration.
private static final String ELEM_FORMAT = "format";
-
+
private static final String ELEM_TEXT = "text";
private static final String ELEM_HTML = "html";
-
// Mail server configuration.
private static final String ELEM_NOTIFICATION = "notification";
-
+
private static final String ELEM_SMTP = "smtp";
private static final String ELEM_SUBJECT = "subject";
private static final String ELEM_PATTERN = "match";
private static final String ELEM_ACTION = "action";
-
+
private static final String ELEM_CATEGORY = "category";
private static final String ACTION_NOTIFY = "notify";
-
- private List<ProgramFilter> _filters;
-
- private Notifier _notifier;
-
- ProgramConfigurationParser() {
- _filters = null;
- _notifier = null;
+
+ private List<ProgramFilter> _filters;
+
+ private Notifier _notifier;
+
+ ProgramConfigurationParser() {
+ _filters = null;
+ _notifier = null;
}
/**
Element categoryElem = program.element(ELEM_CATEGORY);
String category = "";
- if ( categoryElem != null ) {
- category = categoryElem.getText().trim();
+ if (categoryElem != null) {
+ category = categoryElem.getText().trim();
}
-
+
Element actionElem = program.element(ELEM_ACTION);
- ProgramAction action = new RecordProgramAction();
+ ProgramAction action = new RecordProgramAction(1);
if (actionElem != null) {
if (actionElem.getText().equals(ACTION_NOTIFY)) {
action = new InterestingProgramAction(category);
}
}
-
- List<Condition<Program>> regexConditions =
- new ArrayList<Condition<Program>>();
- for (Iterator j = program.elementIterator(ELEM_PATTERN); j.hasNext(); ) {
- Element patternElem = (Element)j.next();
- String fieldName = "name";
- Attribute fieldAttribute = patternElem.attribute("field");
- if ( fieldAttribute != null ) {
- fieldName = fieldAttribute.getText();
+
+ List<Condition<Program>> regexConditions = new ArrayList<Condition<Program>>();
+ for (Iterator j = program.elementIterator(ELEM_PATTERN); j
+ .hasNext();) {
+ Element patternElem = (Element) j.next();
+ String fieldName = "name";
+ Attribute fieldAttribute = patternElem.attribute("field");
+ if (fieldAttribute != null) {
+ fieldName = fieldAttribute.getText();
}
- String pattern = ".*(" + patternElem.getText()
- + ").*";
- regexConditions.add(new PropertyRegexCondition<Program>(fieldName, pattern, true));
+ String pattern = ".*(" + patternElem.getText() + ").*";
+ regexConditions.add(new PropertyRegexCondition<Program>(
+ fieldName, pattern, true));
}
- Condition<Program> condition = new AndCondition<Program>(regexConditions);
+ Condition<Program> condition = new AndCondition<Program>(
+ regexConditions);
filters.add(new ProgramFilter(condition, action));
}
_filters = filters;
-
+
Element notifier = root.element(ELEM_NOTIFICATION);
_notifier = parseNotifier(notifier);
-
+
} catch (DocumentException e) {
throw new RuntimeException("Error parsing program configuraiton", e);
}
}
-
+
/**
* Parses the notifier
+ *
* @return Notifier
*/
- private Notifier parseNotifier(Element aNotifier) {
+ private Notifier parseNotifier(Element aNotifier) {
String from = aNotifier.elementTextTrim(ELEM_FROM);
String to = aNotifier.elementTextTrim(ELEM_TO);
String subject = aNotifier.elementTextTrim(ELEM_SUBJECT);
-
+
Element smtp = aNotifier.element(ELEM_SMTP);
- MailServer server = parseMailServer( smtp );
-
+ MailServer server = parseMailServer(smtp);
+
Element format = aNotifier.element(ELEM_FORMAT);
String htmlXslt = format.elementTextTrim(ELEM_HTML);
String textXslt = format.elementTextTrim(ELEM_TEXT);
-
+
return new MailNotifier(from, to, subject, htmlXslt, textXslt, server);
}
/**
* Parses the mail server from the XML.
- * @param aSmtp Mail server configuration.
+ *
+ * @param aSmtp
+ * Mail server configuration.
* @return Mail server.
*/
- private MailServer parseMailServer( Element aSmtp ) {
+ private MailServer parseMailServer(Element aSmtp) {
String host = aSmtp.elementTextTrim(ELEM_HOST);
Element portElem = aSmtp.element(ELEM_PORT);
- int port = 25;
- if ( portElem != null ) {
+ int port = DEFAULT_SMTP_PORT;
+ if (portElem != null) {
port = Integer.valueOf(portElem.getTextTrim());
}
String username = aSmtp.elementTextTrim(ELEM_USERNAME);
String password = aSmtp.elementTextTrim(ELEM_PASSWORD);
-
+
MailServer server = new MailServer(host, port, username, password);
return server;
}
-
+
/**
* Returns the list of program filters.
+ *
* @return Filter list.
*/
- public List<ProgramFilter> getFilters() {
+ public List<ProgramFilter> getFilters() {
return _filters;
}
-
+
/**
- * Returns the notifier to use.
+ * Returns the notifier to use.
+ *
* @return Notifier.
*/
- public Notifier getNotifier() {
- return _notifier;
+ public Notifier getNotifier() {
+ return _notifier;
}
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.crawler.kiss.main;
import org.wamblee.crawler.kiss.guide.Program;
import org.wamblee.crawler.kiss.guide.TVGuide;
-
/**
- * Obtains a list of interesting programs from a TV guide and decides
- * what to do with them.
+ * Obtains a list of interesting programs from a TV guide and decides what to do
+ * with them.
*/
public class ProgramFilter {
-
- private Condition<Program> _condition;
-
- private ProgramAction _action;
-
- public ProgramFilter(Condition<Program> aCondition, ProgramAction aAction) {
- _condition = aCondition;
- _action = aAction;
+
+ private Condition<Program> _condition;
+
+ private ProgramAction _action;
+
+ /**
+ * Constructs the program filter.
+ * @param aCondition Condition used to find interesting programs.
+ * @param aAction Corresponding action to execute for matching programs.
+ */
+ public ProgramFilter(Condition<Program> aCondition, ProgramAction aAction) {
+ _condition = aCondition;
+ _action = aAction;
}
-
- public ProgramAction getAction() {
+
+ /**
+ * Gets the action.
+ * @return Action.
+ */
+ public ProgramAction getAction() {
return _action;
}
-
- public List<Program> apply(TVGuide aGuide) {
+
+ /**
+ * Applies the filter to a TV guide.
+ * @param aGuide TV guide.
+ * @return List of matching programs.
+ */
+ public List<Program> apply(TVGuide aGuide) {
MatchVisitor matcher = new MatchVisitor(_condition);
aGuide.accept(matcher);
- return matcher.getMatches();
+ return matcher.getMatches();
}
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.crawler.kiss.main;
import org.wamblee.crawler.kiss.guide.Program;
-
/**
- * Represents an action to record a program.
+ * Represents an action to record a program.
*/
public class RecordProgramAction implements ProgramAction {
-
- private int _priority;
-
+
+ private int _priority;
+
/**
- * Constructs the action.
- *
+ * Constructs the action.
+ * @param aPriority Priority of the recording action. Lower values mean
+ * higher priority.
*/
- public void ReportProgramAction(int aPriority) {
- _priority = aPriority;
+ public RecordProgramAction(int aPriority) {
+ _priority = aPriority;
}
- /* (non-Javadoc)
- * @see org.wamblee.crawler.kiss.ProgramAction#execute(org.wamblee.crawler.kiss.Program, org.wamblee.crawler.kiss.Report)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.wamblee.crawler.kiss.ProgramAction#execute(org.wamblee.crawler.kiss.Program,
+ * org.wamblee.crawler.kiss.Report)
*/
- public void execute(Program aProgram, ProgramActionExecutor aReport) {
+ public void execute(Program aProgram, ProgramActionExecutor aReport) {
aReport.recordProgram(_priority, aProgram);
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.crawler.kiss.main;
/**
- * Access to system properties for the crawler.
+ * Access to system properties for the crawler.
*/
public final class SystemProperties {
-
+
private static final String DEBUG_PROPERTY = "kiss.debug";
+
private static final String NO_PROGRAM_DETAILS = "kiss.nodetails";
- private static final String DISABLE_RECORD = "kiss.norecord";
-
+
+ private static final String DISABLE_RECORD = "kiss.norecord";
+
/**
- * Disabled constructor.
- *
+ * Disabled constructor.
+ *
*/
- private SystemProperties() {
- // Empty.
+ private SystemProperties() {
+ // Empty.
}
/**
- * Determines if the system is run in debug mode. When in debug mode, less extensive crawling is done.
- * @return True iff we are running in debug mode.
+ * Determines if the system is run in debug mode. When in debug mode, less
+ * extensive crawling is done.
+ *
+ * @return True iff we are running in debug mode.
*/
- public static boolean isDebugMode() {
- return System.getProperties().getProperty(DEBUG_PROPERTY) != null;
+ public static boolean isDebugMode() {
+ return System.getProperties().getProperty(DEBUG_PROPERTY) != null;
}
-
+
/**
- * Determines if no program details are required.
- * @return True iff no program details are required.
+ * Determines if no program details are required.
+ *
+ * @return True iff no program details are required.
*/
- public static boolean isNoProgramDetailsRequired() {
- return System.getProperties().getProperty(NO_PROGRAM_DETAILS) != null;
+ public static boolean isNoProgramDetailsRequired() {
+ return System.getProperties().getProperty(NO_PROGRAM_DETAILS) != null;
}
-
/**
- * Determines if recording is disabled.
- * @return True iff no recording should be done.
+ * Determines if recording is disabled.
+ *
+ * @return True iff no recording should be done.
*/
- public static boolean isRecordDisabled() {
- return System.getProperties().getProperty(DISABLE_RECORD) != null;
+ public static boolean isRecordDisabled() {
+ return System.getProperties().getProperty(DISABLE_RECORD) != null;
}
-
+
}
* Mail server.
*/
public class MailServer {
-
- private String _host;
+
+ private String _host;
+
private int _port;
+
private String _username;
+
private String _password;
/**
- * Constructs the mail server interface.
- * @param aHost Host name of the SMTP server.
- * @param aPort Port name of the SMTP server.
- * @param aUsername Username to use for authentication or null if no authentication is
- * required.
- * @param aPassword Password to use for authentication or null if no authenticatio is
- * required.
+ * Constructs the mail server interface.
+ *
+ * @param aHost
+ * Host name of the SMTP server.
+ * @param aPort
+ * Port name of the SMTP server.
+ * @param aUsername
+ * Username to use for authentication or null if no
+ * authentication is required.
+ * @param aPassword
+ * Password to use for authentication or null if no authenticatio
+ * is required.
*/
- public MailServer(String aHost, int aPort, String aUsername, String aPassword) {
+ public MailServer(String aHost, int aPort, String aUsername,
+ String aPassword) {
_host = aHost;
_port = aPort;
_username = aUsername;
_password = aPassword;
}
-
+
/**
- * Sends an e-mail.
- * @param aMail Mail to send.
- * @throws EmailException In case of problems sending the mail.
+ * Sends an e-mail.
+ *
+ * @param aMail
+ * Mail to send.
+ * @throws EmailException
+ * In case of problems sending the mail.
*/
public void send(Email aMail) throws EmailException {
Properties props = new Properties();
props.put("mail.smtp.host", _host);
props.put("mail.smtp.port", "" + _port);
- Session mailSession = Session.getInstance(props, new UsernamePasswordAuthenticator(_username, _password));
+ Session mailSession = Session.getInstance(props,
+ new UsernamePasswordAuthenticator(_username, _password));
aMail.setMailSession(mailSession);
aMail.send();
}
package org.wamblee.crawler.kiss.notification;
/**
- * Notification exception thrown in case of problems sending
- * a notification to a user.
- *
+ * Notification exception thrown in case of problems sending a notification to a
+ * user.
+ *
*/
public class NotificationException extends Exception {
/**
- * Constructs the notification.
- * @param aMsg Message.
+ * Constructs the notification.
+ *
+ * @param aMsg
+ * Message.
*/
- public NotificationException(String aMsg) {
+ public NotificationException(String aMsg) {
super(aMsg);
}
-
+
/**
- * Constructs the notification.
- * @param aMsg Message.
- * @param aCause Cause.
+ * Constructs the notification.
+ *
+ * @param aMsg
+ * Message.
+ * @param aCause
+ * Cause.
*/
- public NotificationException(String aMsg, Throwable aCause) {
+ public NotificationException(String aMsg, Throwable aCause) {
super(aMsg, aCause);
}
}
/**
* Object used to send notifications about the actions of the crawler.
- *
+ *
*/
public interface Notifier {
/**
- * Sends a notification.
- * @param aReport Report to send.
+ * Sends a notification.
+ *
+ * @param aReport
+ * Report to send.
*/
void send(Element aReport) throws NotificationException;
}
import javax.mail.PasswordAuthentication;
/**
- * Authenticator to supply username and password to the mail server
- * (if needed).
- *
+ * Authenticator to supply username and password to the mail server (if needed).
+ *
*/
public class UsernamePasswordAuthenticator extends Authenticator {
-
- private String _username;
- private String _password;
+
+ private String _username;
+
+ private String _password;
/**
* Constructs the authenticator.
- * @param aUsername User name.
- * @param aPassword Password.
+ *
+ * @param aUsername
+ * User name.
+ * @param aPassword
+ * Password.
*/
- public UsernamePasswordAuthenticator(String aUsername, String aPassword) {
- _username = aUsername;
- _password = aPassword;
+ public UsernamePasswordAuthenticator(String aUsername, String aPassword) {
+ _username = aUsername;
+ _password = aPassword;
}
-
+
/*
- * (non-Javadoc)
+ * (non-Javadoc)
+ *
* @see javax.mail.Authenticator#getPasswordAuthentication()
*/
@Override
- protected PasswordAuthentication getPasswordAuthentication( ) {
- if ( _username == null ) {
- return null;
+ protected PasswordAuthentication getPasswordAuthentication() {
+ if (_username == null) {
+ return null;
}
return new PasswordAuthentication(_username, _password);
}