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
Hide line numbers
1: <% 2: def context2 = context.getContext(); 3: def store = xwiki.getXWiki().getStore().getStore(); 4: def wikilist = xwiki.isVirtual() ? xwiki.wikimanager.getAllWikis() : [ "xwiki" ]; 5: def indexes = xwiki.getDocument("Admin.CheckIndexesSQL").getContent().split("\n") 6: 7: if (!wikilist.contains("xwiki")) 8: wikilist.add(0, "xwiki") 9: def creationNeeded = false; 10: for(wiki in wikilist) { 11: creationNeededForThisWiki = false; 12: try { 13: store.beginTransaction(context2); 14: def session = store.getSession(context2); 15: def connection = session.connection(); 16: def stmt = connection.createStatement(); 17: stmt.execute("show indexes from ${wiki}.xwikiattrecyclebin where column_name='xda_deleter'"); 18: def rset = stmt.getResultSet(); 19: def result = null; 20: try { 21: rset.first(); 22: result = rset.getObject(1); 23: } catch (Exception e2) {} 24: if (result!=null && result.equals("xwikiattrecyclebin")) { 25: println "* Indexes created for wiki ${wiki}" 26: } else { 27: println "* <font color='red'>Indexes not created for wiki ${wiki}</font>" 28: creationNeeded = true; 29: creationNeededForThisWiki = true; 30: } 31: stmt.close(); 32: } catch (Exception e) { 33: println "* <font color='red'>Failed to check indexes for wiki ${wiki}</font>: " + e.getMessage() 34: } finally { 35: store.endTransaction(context2, false); 36: } 37: if (creationNeededForThisWiki && request.confirm=="1") { 38: try { 39: println "* Indexes will be created for wiki ${wiki}" 40: store.beginTransaction(context2); 41: def session = store.getSession(context2); 42: def connection = session.connection(); 43: connection.setCatalog(wiki.toString()); 44: for (sql in indexes) { 45: println "* Running sql: ${sql}"; 46: def stmt = connection.createStatement(); 47: try { 48: stmt.execute(sql.replaceAll(";", "")); 49: stmt.close(); 50: } catch (Exception e2) { 51: println "* Error running sql: ${sql} " + e2.getMessage(); 52: } finally { 53: stmt.close(); 54: } 55: } 56: } catch (Exception e) { 57: println "* <font color='red'>Error creating indexes for wiki ${wiki}: </font>" + e.getMessage(); 58: } finally { 59: store.endTransaction(context2, false); 60: } 61: } 62: 63: } 64: 65: if (creationNeeded && request.confirm!="1") { 66: println "[Confirm creation of indexes>$doc.fullName?confirm=1]" 67: } 68: %>