52 |
52 |
*/
|
53 |
53 |
public class MetacatIndexServlet extends HttpServlet {
|
54 |
54 |
|
55 |
|
//Use the file prefix to indicate this is a absolute path.
|
56 |
|
// seet http://www.docjar.com/docs/api/org/springframework/context/support/FileSystemXmlApplicationContext.html
|
|
55 |
// Use the file prefix to indicate this is a absolute path.
|
|
56 |
// see http://www.docjar.com/docs/api/org/springframework/context/support/FileSystemXmlApplicationContext.html
|
57 |
57 |
private static final String FILEPREFIX = "file:";
|
58 |
58 |
|
59 |
59 |
private static Log log = LogFactory.getLog(MetacatIndexServlet.class);
|
... | ... | |
64 |
64 |
public void init(ServletConfig config) throws ServletException {
|
65 |
65 |
//System.out.println("++++++++++++++++++++++++------------------- start the servlet");
|
66 |
66 |
|
67 |
|
// load the metacat.prioerties into D1 Settings utility
|
68 |
|
// this gives us access to all metacat properties as well as
|
69 |
|
// overriding the d1 properties as needed
|
|
67 |
initializeSharedConfiguration(config);
|
|
68 |
|
|
69 |
// initialize the application using the configured application-context
|
|
70 |
URL url = getClass().getResource("/index-processor-context.xml");
|
|
71 |
//System.out.println("the url is "+url);
|
|
72 |
//System.out.println("the path is "+url.getPath());
|
|
73 |
//System.out.println("the file is "+url.getPath());
|
|
74 |
ApplicationController controller = new ApplicationController(FILEPREFIX + url.getFile());
|
|
75 |
List<SolrIndex> list = controller.getSolrIndexes();
|
|
76 |
//System.out.println("++++++++++++++++++++++++------------------- the size is "+list.size());
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Loads the metacat.prioerties into D1 Settings utility
|
|
81 |
* this gives us access to all metacat properties as well as
|
|
82 |
* overriding any properties as needed.
|
|
83 |
*
|
|
84 |
* Makes sure shared Hazelcast configuration file location is set
|
|
85 |
*
|
|
86 |
* @param config the servlet config
|
|
87 |
*/
|
|
88 |
private void initializeSharedConfiguration(ServletConfig config) {
|
|
89 |
|
70 |
90 |
try {
|
71 |
91 |
// find the sibling metacat.properties file
|
72 |
92 |
String metacatPropertiesFilePath = config.getServletContext().getInitParameter("metacat.properties.path");
|
... | ... | |
76 |
96 |
} catch (ConfigurationException e) {
|
77 |
97 |
log.error("Could not initialize shared Metacat properties. " + e.getMessage(), e);
|
78 |
98 |
}
|
79 |
|
// make sure hazelcast configuration is defined
|
|
99 |
|
|
100 |
// make sure hazelcast configuration is defined so that
|
80 |
101 |
String hzConfigFileName = Settings.getConfiguration().getString("dataone.hazelcast.configFilePath");
|
81 |
102 |
if (hzConfigFileName == null) {
|
82 |
103 |
// use default metacat hazelcast.xml file in metacat deployment
|
... | ... | |
88 |
109 |
// set it for other parts of the code
|
89 |
110 |
Settings.getConfiguration().setProperty("dataone.hazelcast.configFilePath", hzConfigFileName);
|
90 |
111 |
}
|
91 |
|
|
92 |
|
URL url = getClass().getResource("/index-processor-context.xml");
|
93 |
|
//System.out.println("the url is "+url);
|
94 |
|
//System.out.println("the path is "+url.getPath());
|
95 |
|
//System.out.println("the file is "+url.getPath());
|
96 |
|
ApplicationController controller = new ApplicationController(FILEPREFIX+url.getFile());
|
97 |
|
List<SolrIndex> list = controller.getSolrIndexes();
|
98 |
|
//System.out.println("++++++++++++++++++++++++------------------- the size is "+list.size());
|
99 |
112 |
}
|
100 |
113 |
|
101 |
114 |
/**
|
clean up configuration initialization