General Actions:
Log-in
Register
Wiki:
Main wiki
▼
:
Document Index
»
Space:
Admin
▼
:
Document Index
»
Page:
CheckIndexes
Search
en
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
WebHome
»
XWiki and MySQL Configuration Check
»
XWiki Database Indexes Check
Wiki source code of
XWiki Database Indexes Check
Last modified by
Administrator
on 2010/09/24 19:35
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
<% def context2 = context.getContext(); def store = xwiki.getXWiki().getStore().getStore(); def wikilist = xwiki.isVirtual() ? xwiki.wikimanager.getAllWikis() : [ "xwiki" ]; def indexes = xwiki.getDocument("Admin.CheckIndexesSQL").getContent().split("\n") if (!wikilist.contains("xwiki")) wikilist.add(0, "xwiki") def creationNeeded = false; for(wiki in wikilist) { creationNeededForThisWiki = false; try { store.beginTransaction(context2); def session = store.getSession(context2); def connection = session.connection(); def stmt = connection.createStatement(); stmt.execute("show indexes from ${wiki}.xwikiattrecyclebin where column_name='xda_deleter'"); def rset = stmt.getResultSet(); def result = null; try { rset.first(); result = rset.getObject(1); } catch (Exception e2) {} if (result!=null && result.equals("xwikiattrecyclebin")) { println "* Indexes created for wiki ${wiki}" } else { println "* <font color='red'>Indexes not created for wiki ${wiki}</font>" creationNeeded = true; creationNeededForThisWiki = true; } stmt.close(); } catch (Exception e) { println "* <font color='red'>Failed to check indexes for wiki ${wiki}</font>: " + e.getMessage() } finally { store.endTransaction(context2, false); } if (creationNeededForThisWiki && request.confirm=="1") { try { println "* Indexes will be created for wiki ${wiki}" store.beginTransaction(context2); def session = store.getSession(context2); def connection = session.connection(); connection.setCatalog(wiki.toString()); for (sql in indexes) { println "* Running sql: ${sql}"; def stmt = connection.createStatement(); try { stmt.execute(sql.replaceAll(";", "")); stmt.close(); } catch (Exception e2) { println "* Error running sql: ${sql} " + e2.getMessage(); } finally { stmt.close(); } } } catch (Exception e) { println "* <font color='red'>Error creating indexes for wiki ${wiki}: </font>" + e.getMessage(); } finally { store.endTransaction(context2, false); } } } if (creationNeeded && request.confirm!="1") { println "[Confirm creation of indexes>$doc.fullName?confirm=1]" } %>