KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > business > referrers > ReferrerProcessingJob


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * ReferrerProcessingJob.java
20  *
21  * Created on December 16, 2005, 6:26 PM
22  */

23
24 package org.apache.roller.business.referrers;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.apache.roller.RollerException;
31 import org.apache.roller.business.runnable.Job;
32 import org.apache.roller.model.RefererManager;
33 import org.apache.roller.model.RollerFactory;
34
35
36 /**
37  * A simple Job which processes an IncomingReferrer.
38  *
39  * @author Allen Gilliland
40  */

41 public class ReferrerProcessingJob implements Job {
42     
43     private static Log mLogger = LogFactory.getLog(ReferrerProcessingJob.class);
44     
45     Map JavaDoc inputs = null;
46     IncomingReferrer referrer = null;
47     
48     public ReferrerProcessingJob() {}
49     
50     
51     /**
52      * Execute job.
53      *
54      * We simply pass the referrer into the RefererManager to handle the details.
55      */

56     public void execute() {
57         
58         if(this.referrer == null)
59             return;
60         
61         mLogger.debug("PROCESSING: "+referrer.getRequestUrl());
62         
63         // process a referrer
64
try {
65             RefererManager refMgr = RollerFactory.getRoller().getRefererManager();
66             refMgr.processReferrer(referrer.getRequestUrl(),
67                                    referrer.getReferrerUrl(),
68                                    referrer.getWeblogHandle(),
69                                    referrer.getWeblogAnchor(),
70                                    referrer.getWeblogDateString());
71             
72             RollerFactory.getRoller().flush();
73         } catch(RollerException re) {
74             // trouble
75
mLogger.warn("Trouble processing referrer", re);
76         }
77     }
78     
79     
80     /**
81      * Set input.
82      */

83     public void input(Map JavaDoc input) {
84         this.inputs = input;
85         
86         // we are looking for the "referrer" key
87
Object JavaDoc ref = input.get("referrer");
88         
89         if(ref instanceof IncomingReferrer) {
90             this.referrer = (IncomingReferrer) ref;
91         }
92     }
93     
94     
95     /**
96      * Get output.
97      */

98     public Map JavaDoc output() {
99         
100         return null;
101     }
102     
103 }
104
Popular Tags