001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: /*
019: * ReferrerProcessingJob.java
020: *
021: * Created on December 16, 2005, 6:26 PM
022: */
023:
024: package org.apache.roller.business.referrers;
025:
026: import java.util.HashMap;
027: import java.util.Map;
028: import org.apache.commons.logging.Log;
029: import org.apache.commons.logging.LogFactory;
030: import org.apache.roller.RollerException;
031: import org.apache.roller.business.runnable.Job;
032: import org.apache.roller.business.referrers.RefererManager;
033: import org.apache.roller.business.RollerFactory;
034:
035: /**
036: * A simple Job which processes an IncomingReferrer.
037: *
038: * @author Allen Gilliland
039: */
040: public class ReferrerProcessingJob implements Job {
041:
042: private static Log mLogger = LogFactory
043: .getLog(ReferrerProcessingJob.class);
044:
045: Map inputs = null;
046: IncomingReferrer referrer = null;
047:
048: public ReferrerProcessingJob() {
049: }
050:
051: /**
052: * Execute job.
053: *
054: * We simply pass the referrer into the RefererManager to handle the details.
055: */
056: public void execute() {
057:
058: if (this .referrer == null)
059: return;
060:
061: mLogger.debug("PROCESSING: " + referrer.getRequestUrl());
062:
063: // process a referrer
064: try {
065: RefererManager refMgr = RollerFactory.getRoller()
066: .getRefererManager();
067: refMgr.processReferrer(referrer.getRequestUrl(), referrer
068: .getReferrerUrl(), referrer.getWeblogHandle(),
069: referrer.getWeblogAnchor(), referrer
070: .getWeblogDateString());
071:
072: RollerFactory.getRoller().flush();
073: } catch (RollerException re) {
074: // trouble
075: mLogger.warn("Trouble processing referrer", re);
076: }
077: }
078:
079: /**
080: * Set input.
081: */
082: public void input(Map input) {
083: this .inputs = input;
084:
085: // we are looking for the "referrer" key
086: Object ref = input.get("referrer");
087:
088: if (ref instanceof IncomingReferrer) {
089: this .referrer = (IncomingReferrer) ref;
090: }
091: }
092:
093: /**
094: * Get output.
095: */
096: public Map output() {
097:
098: return null;
099: }
100:
101: }
|