KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > web > servlet > UpdateLibrarySearchIndex


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: UpdateLibrarySearchIndex.java,v $
31  * Revision 1.3 2005/04/10 20:09:46 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:47 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:52:07 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.4 2004/11/12 18:16:06 colinmacleod
45  * Ordered imports.
46  *
47  * Revision 1.3 2004/11/12 15:57:16 colinmacleod
48  * Removed dependencies on SSLEXT.
49  * Moved Persistence classes to ivata masks.
50  *
51  * Revision 1.2 2004/11/03 15:55:46 colinmacleod
52  * Changed todo comments to TODO: all caps.
53  *
54  * Revision 1.1 2004/09/30 14:59:06 colinmacleod
55  * Added methods to sanitize the entire library and update the search index.
56  *
57  * -----------------------------------------------------------------------------
58  */

59 package com.ivata.groupware.web.servlet;
60
61 import java.io.IOException JavaDoc;
62
63 import javax.servlet.ServletException JavaDoc;
64 import javax.servlet.http.HttpServlet JavaDoc;
65 import javax.servlet.http.HttpServletRequest JavaDoc;
66 import javax.servlet.http.HttpServletResponse JavaDoc;
67
68 import org.apache.log4j.Category;
69 import org.picocontainer.PicoContainer;
70
71 import com.ivata.groupware.admin.security.Security;
72 import com.ivata.groupware.admin.security.server.SecuritySession;
73 import com.ivata.groupware.business.library.Library;
74 import com.ivata.groupware.container.PicoContainerFactory;
75 import com.ivata.mask.util.SystemException;
76
77 /**
78  * <p>
79  * TODO
80  * </p>
81  *
82  * @since Aug 9, 2004
83  * @author Colin MacLeod
84  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
85  * @version $Revision: 1.3 $
86  */

87
88 public class UpdateLibrarySearchIndex extends HttpServlet JavaDoc {
89     /**
90      * <p>
91      * <strong>Log4J</strong> logger.
92      * </p>
93      */

94     private static Category log = Category.getInstance(UpdateLibrarySearchIndex.class);
95
96     /**
97      * <p>Clean up resources.</p>
98      */

99     public void destroy() {}
100
101     public void doGet(final HttpServletRequest JavaDoc request,
102             final HttpServletResponse JavaDoc response) throws ServletException JavaDoc, IOException JavaDoc {
103         log.info("START Update library search index.");
104
105         PicoContainer container;
106         try {
107             container = PicoContainerFactory.getInstance()
108                 .getGlobalContainer();
109         } catch (SystemException e) {
110             throw new ServletException JavaDoc(e);
111         }
112         Security security = (Security) container.getComponentInstance(Security.class);
113         try {
114             // get a session container - we need a session for the date formatter
115
SecuritySession session = security.loginGuest();
116             container = session.getContainer();
117             Library library = (Library) container.getComponentInstance(Library.class);
118             library.updateSearchIndex(session);
119         } catch (SystemException e) {
120             e.printStackTrace();
121             log.error(e);
122         }
123
124         log.info("END Update library search index.");
125     }
126
127     /**
128      * <p>Initialize global variables.</p>
129      */

130     public void init() throws ServletException JavaDoc {}
131
132 }
133
Popular Tags