1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.portal.portlets.admin;
17
18
19 import org.apache.ecs.ConcreteElement;
20 import org.apache.ecs.ElementContainer;
21 import org.apache.ecs.html.A;
22 import org.apache.ecs.html.B;
23 import org.apache.ecs.html.BR;
24 import org.apache.ecs.html.LI;
25 import org.apache.ecs.html.UL;
26
27
28 import org.apache.turbine.util.DynamicURI;
29 import org.apache.turbine.util.ParameterParser;
30 import org.apache.turbine.util.RunData;
31
32
33
34 import org.apache.jetspeed.portal.portlets.*;
35 import org.apache.jetspeed.services.urlmanager.*;
36
37 import java.util.*;
38
39 /***
40 Shows the user what URLs are considered bad.
41
42 @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
43 @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
44 @version $Id: BadURLManagerPortlet.java,v 1.13 2004/02/23 03:26:19 jford Exp $
45 */
46 public class BadURLManagerPortlet extends AbstractPortlet {
47
48 public static final String RETRY_URL = "retry";
49
50
51 public ConcreteElement getContent( RunData rundata ) {
52
53 String url = rundata.getParameters().getString( RETRY_URL );
54
55 if ( url != null ) {
56 URLManager.unregister(url);
57 rundata.getParameters().remove( RETRY_URL );
58 }
59
60
61
62 ElementContainer root = new ElementContainer();
63
64 List urls = URLManager.list( URLManagerService.STATUS_BAD );
65
66 root.addElement( "The following " +
67 urls.size() +
68 " URL(s) are considered bad: " );
69
70 root.addElement( new BR() );
71
72 root.addElement( "Click on a url to take it out of the list" +
73 " and retry it in when requested. " );
74
75 root.addElement( new BR() );
76
77 UL ul = new UL();
78
79 DynamicURI uri = new DynamicURI( rundata );
80
81 ParameterParser params = rundata.getParameters();
82 uri.addQueryData( params );
83
84 Iterator i = urls.iterator();
85
86 while ( i.hasNext() ) {
87 URLInfo info = URLManager.getInfo( (String)i.next() );
88
89
90 if( info != null ) {
91 uri.removeQueryData( RETRY_URL );
92 uri.addQueryData(RETRY_URL, info.getURL());
93 ul.addElement( new LI()
94 .addElement( new A(uri.toString() )
95 .addElement( info.getURL() ) )
96 .addElement( new B( info.getMessage() ) ) );
97 }
98 }
99
100 root.addElement( ul );
101
102 java.util.Hashtable rt = URLFetcher.getRealtimeURLs();
103
104 root.addElement( "The following " +
105 rt.size() +
106 " URL(s) are being loaded: " );
107
108 root.addElement( new BR() );
109 ul = new UL();
110
111 java.util.Enumeration en = rt.keys();
112 while (en.hasMoreElements()) {
113 String key = (String)en.nextElement();
114 LI li = new LI().addElement( key )
115 .addElement( " - by " );
116 if (rt.get(key) != null )
117 li.addElement( String.valueOf(((Vector)rt.get(key)).size()) )
118 .addElement( " threads." );
119 ul.addElement( li );
120 }
121
122 root.addElement( ul );
123
124
125
126 return root;
127 }
128
129 public void init() {
130 this.setTitle( "BadURLManager" );
131
132 this.setDescription( "Shows the admin what URLs are considered bad." );
133 }
134
135 public boolean getAllowEdit(RunData rundata) {
136 return false;
137 }
138
139 public boolean getAllowMaximize(RunData rundata) {
140 return false;
141 }
142
143 }