1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16packageorg.apache.jetspeed.portal.portlets.admin;
1718//ecs stuff19import org.apache.ecs.ConcreteElement;
20import org.apache.ecs.ElementContainer;
21import org.apache.ecs.html.A;
22import org.apache.ecs.html.B;
23import org.apache.ecs.html.BR;
24import org.apache.ecs.html.LI;
25import org.apache.ecs.html.UL;
2627//turbine stuff28import org.apache.turbine.util.DynamicURI;
29import org.apache.turbine.util.ParameterParser;
30import org.apache.turbine.util.RunData;
313233//jetspeed stuff34importorg.apache.jetspeed.portal.portlets.*;
35importorg.apache.jetspeed.services.urlmanager.*;
3637import java.util.*;
3839/***40Shows the user what URLs are considered bad.4142@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*/46publicclassBadURLManagerPortletextendsAbstractPortlet {
4748publicstaticfinal String RETRY_URL = "retry";
495051public ConcreteElement getContent( RunData rundata ) {
5253 String url = rundata.getParameters().getString( RETRY_URL );
5455if ( url != null ) {
56 URLManager.unregister(url);
57 rundata.getParameters().remove( RETRY_URL );
58 }
59606162 ElementContainer root = new ElementContainer();
6364 List urls = URLManager.list( URLManagerService.STATUS_BAD );
6566 root.addElement( "The following " +
67 urls.size() +
68" URL(s) are considered bad: " );
6970 root.addElement( new BR() );
7172 root.addElement( "Click on a url to take it out of the list" +
73" and retry it in when requested. " );
7475 root.addElement( new BR() );
7677 UL ul = new UL();
78//FIXME: the getReason() call has to be escaped from HTML markup, CR&LF79 DynamicURI uri = new DynamicURI( rundata );
8081 ParameterParser params = rundata.getParameters();
82 uri.addQueryData( params );
8384 Iterator i = urls.iterator();
8586while ( i.hasNext() ) {
87URLInfo info = URLManager.getInfo( (String)i.next() );
88/* It can happen that url is no longer in list while89 we are processing */90if( 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 }
99100 root.addElement( ul );
101102 java.util.Hashtable rt = URLFetcher.getRealtimeURLs();
103104 root.addElement( "The following " +
105 rt.size() +
106" URL(s) are being loaded: " );
107108 root.addElement( new BR() );
109 ul = new UL();
110111 java.util.Enumeration en = rt.keys();
112while (en.hasMoreElements()) {
113 String key = (String)en.nextElement();
114 LI li = new LI().addElement( key )
115 .addElement( " - by " );
116if (rt.get(key) != null )
117 li.addElement( String.valueOf(((Vector)rt.get(key)).size()) )
118 .addElement( " threads." );
119 ul.addElement( li );
120 }
121122 root.addElement( ul );
123124125126return root;
127 }
128129publicvoid init() {
130this.setTitle( "BadURLManager" );
131132this.setDescription( "Shows the admin what URLs are considered bad." );
133 }
134135publicboolean getAllowEdit(RunData rundata) {
136return false;
137 }
138139publicboolean getAllowMaximize(RunData rundata) {
140return false;
141 }
142143 }