You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
(57) |
Apr
(103) |
May
(164) |
Jun
(139) |
Jul
(173) |
Aug
(196) |
Sep
(221) |
Oct
(333) |
Nov
(214) |
Dec
(88) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(163) |
Feb
(165) |
Mar
(98) |
Apr
(93) |
May
(199) |
Jun
(118) |
Jul
(200) |
Aug
(212) |
Sep
(185) |
Oct
(297) |
Nov
(437) |
Dec
(272) |
| 2006 |
Jan
(542) |
Feb
(329) |
Mar
(267) |
Apr
(332) |
May
(267) |
Jun
(130) |
Jul
(161) |
Aug
(348) |
Sep
(166) |
Oct
(305) |
Nov
(173) |
Dec
(173) |
| 2007 |
Jan
(199) |
Feb
(118) |
Mar
(133) |
Apr
(200) |
May
(208) |
Jun
(146) |
Jul
(198) |
Aug
(146) |
Sep
(187) |
Oct
(182) |
Nov
(181) |
Dec
(83) |
| 2008 |
Jan
(252) |
Feb
(124) |
Mar
(124) |
Apr
(101) |
May
(143) |
Jun
(122) |
Jul
(129) |
Aug
(60) |
Sep
(80) |
Oct
(89) |
Nov
(54) |
Dec
(112) |
| 2009 |
Jan
(88) |
Feb
(145) |
Mar
(105) |
Apr
(164) |
May
(123) |
Jun
(154) |
Jul
(374) |
Aug
(341) |
Sep
(219) |
Oct
(137) |
Nov
(373) |
Dec
(240) |
| 2010 |
Jan
(197) |
Feb
(270) |
Mar
(253) |
Apr
(150) |
May
(102) |
Jun
(51) |
Jul
(300) |
Aug
(512) |
Sep
(254) |
Oct
(258) |
Nov
(288) |
Dec
(143) |
| 2011 |
Jan
(238) |
Feb
(179) |
Mar
(253) |
Apr
(332) |
May
(248) |
Jun
(255) |
Jul
(216) |
Aug
(282) |
Sep
(146) |
Oct
(77) |
Nov
(86) |
Dec
(69) |
| 2012 |
Jan
(172) |
Feb
(234) |
Mar
(229) |
Apr
(101) |
May
(212) |
Jun
(267) |
Jul
(129) |
Aug
(210) |
Sep
(239) |
Oct
(271) |
Nov
(368) |
Dec
(220) |
| 2013 |
Jan
(179) |
Feb
(155) |
Mar
(59) |
Apr
(47) |
May
(99) |
Jun
(158) |
Jul
(185) |
Aug
(16) |
Sep
(16) |
Oct
(7) |
Nov
(20) |
Dec
(12) |
| 2014 |
Jan
(21) |
Feb
(17) |
Mar
(18) |
Apr
(13) |
May
(27) |
Jun
(15) |
Jul
(19) |
Aug
(22) |
Sep
(30) |
Oct
(16) |
Nov
(19) |
Dec
(16) |
| 2015 |
Jan
(14) |
Feb
(24) |
Mar
(33) |
Apr
(41) |
May
(14) |
Jun
(80) |
Jul
(53) |
Aug
(8) |
Sep
(7) |
Oct
(15) |
Nov
(13) |
Dec
(2) |
| 2016 |
Jan
(22) |
Feb
(12) |
Mar
(30) |
Apr
(6) |
May
(33) |
Jun
(16) |
Jul
(8) |
Aug
(20) |
Sep
(12) |
Oct
(18) |
Nov
(12) |
Dec
(11) |
| 2017 |
Jan
(24) |
Feb
(26) |
Mar
(47) |
Apr
(23) |
May
(19) |
Jun
(14) |
Jul
(28) |
Aug
(30) |
Sep
(17) |
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
(73) |
Mar
(90) |
Apr
(42) |
May
(116) |
Jun
(90) |
Jul
(127) |
Aug
(103) |
Sep
(56) |
Oct
(42) |
Nov
(95) |
Dec
(58) |
| 2020 |
Jan
(102) |
Feb
(31) |
Mar
(93) |
Apr
(60) |
May
(57) |
Jun
(45) |
Jul
(29) |
Aug
(32) |
Sep
(44) |
Oct
(86) |
Nov
(51) |
Dec
(71) |
| 2021 |
Jan
(44) |
Feb
(25) |
Mar
(78) |
Apr
(130) |
May
(64) |
Jun
(74) |
Jul
(21) |
Aug
(64) |
Sep
(40) |
Oct
(43) |
Nov
(21) |
Dec
(99) |
| 2022 |
Jan
(154) |
Feb
(64) |
Mar
(45) |
Apr
(95) |
May
(62) |
Jun
(48) |
Jul
(73) |
Aug
(37) |
Sep
(71) |
Oct
(27) |
Nov
(40) |
Dec
(65) |
| 2023 |
Jan
(89) |
Feb
(130) |
Mar
(124) |
Apr
(50) |
May
(93) |
Jun
(46) |
Jul
(45) |
Aug
(68) |
Sep
(62) |
Oct
(71) |
Nov
(108) |
Dec
(82) |
| 2024 |
Jan
(53) |
Feb
(76) |
Mar
(64) |
Apr
(75) |
May
(36) |
Jun
(54) |
Jul
(98) |
Aug
(137) |
Sep
(58) |
Oct
(177) |
Nov
(84) |
Dec
(52) |
| 2025 |
Jan
(70) |
Feb
(53) |
Mar
(72) |
Apr
(47) |
May
(88) |
Jun
(49) |
Jul
(86) |
Aug
(51) |
Sep
(65) |
Oct
(91) |
Nov
(18) |
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
(9) |
|
2
(22) |
3
(2) |
4
(2) |
5
(4) |
6
(8) |
7
|
8
|
|
9
|
10
|
11
|
12
|
13
|
14
|
15
|
|
16
|
17
(3) |
18
(10) |
19
(1) |
20
(1) |
21
(18) |
22
(3) |
|
23
(11) |
24
(2) |
25
|
26
|
27
|
28
(20) |
29
(22) |
|
30
(24) |
31
(1) |
|
|
|
|
|
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-31 21:54:38
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/src/org/exist/xquery/functions Modified Files: FunNumber.java Log Message: Return NaN instead of an exception for values that cannot be converted to a double. Index: FunNumber.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunNumber.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunNumber.java 14 Nov 2004 22:15:12 -0000 1.4 --- FunNumber.java 31 Jan 2005 21:54:05 -0000 1.5 *************** *** 71,76 **** if(arg.getLength() == 0) return DoubleValue.NaN; ! else ! return arg.convertTo(Type.DOUBLE); } } --- 71,81 ---- if(arg.getLength() == 0) return DoubleValue.NaN; ! else { ! try { ! return arg.convertTo(Type.DOUBLE); ! } catch(XPathException e) { ! return DoubleValue.NaN; ! } ! } } } |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 21:18:38
|
Update of /cvsroot/exist/eXist-1.0/samples/xinclude In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26092/samples/xinclude Modified Files: xinclude.xml Added Files: logo.jpg default-style.css Log Message: Index: xinclude.xml =================================================================== RCS file: /cvsroot/exist/eXist-1.0/samples/xinclude/xinclude.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xinclude.xml 29 Oct 2004 21:15:06 -0000 1.4 --- xinclude.xml 30 Jan 2005 21:18:16 -0000 1.5 *************** *** 4,9 **** <book xmlns:xi="" rel="nofollow">http://www.w3.org/2001/XInclude"> <bookinfo> ! <graphic fileref="/exist/logo.jpg"/> ! <style href="/exist/styles/default-style.css"/> <title>Open Source XML Database</title> <author> --- 4,9 ---- <book xmlns:xi="" rel="nofollow">http://www.w3.org/2001/XInclude"> <bookinfo> ! <graphic fileref="logo.jpg"/> ! <style href="default-style.css"/> <title>Open Source XML Database</title> <author> *************** *** 54,58 **** <para>By the way, this page also demonstrates some of the possibilities of eXist's REST interface. All the files required to render this page reside in the database and are ! read from there, including the two XSLT stylesheets used for the formatting.</para> </section> --- 54,58 ---- <para>By the way, this page also demonstrates some of the possibilities of eXist's REST interface. All the files required to render this page reside in the database and are ! read from there, including the logo and the two XSLT stylesheets used for the formatting.</para> </section> --- NEW FILE: logo.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: default-style.css --- body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.4; } p, ul, ol { font-size: 13px; margin-left: 15px; margin-right: 15px; } table { font-size: 13px; } table p { margin: 0px; } #notes { border-top: solid 1px #DEDEDE; } #top { margin-bottom: 5px; display: block; overflow: visible; height: 180px; } #top #menubar { width: 100%; padding-top: 4px; padding-bottom: 4px; margin-top: 5px; border-top: solid 1px #DEDEDE; border-bottom: solid 1px #DEDEDE; } #menubar #header { color: #0A0AA0; text-align: left; font-size: 14pt; font-weight: normal; margin: 0; padding: 0; } @media print { #menubar a { display: none; } } @media screen { #menubar a { margin-left: 10px; color: #666666; } } #footer { padding: 10px; } @media screen { #sidebar { position: absolute; margin-top: 15px; width: 16%; display: block; overflow: visible; } #content2col { position: absolute; left: 18%; width: 81%; margin-top: 15px; display: block; background-color: white; overflow: visible; } #content { position: absolute; left: 18%; width: 62%; margin-top: 15px; display: block; background-color: white; overflow: visible; } #news { position: absolute; width: 18%; left: 82%; margin-top: 15px; display: block; overflow: visible; } #version-info { color: #666666; text-align: right; margin-top: 3px; font-size: 8pt; margin-bottom: 5px; } } .toc { margin-top: 10px; margin-bottom: 5px; font-size: 80%; padding-left: 40px; padding-bottom: 5px; } .tocitem2 { padding-left: 15px; } h1 { font-size: 160%; font-weight: normal; color: white; background-color: #0990EE; border: 1px solid #999; margin-left: 0px; margin-bottom: 15px; margin-top: 0px; padding-left: 5px; padding-right: 5px; padding-bottom: 5px; } h2 { font-size: 160%; font-weight: normal; color: #666666; margin-left: 0px; margin-top: 25px; margin-bottom: 5px; margin-right: 20px; text-align: left; border-bottom: 1px solid ; } h3 { font-size: 12pt; font-weight: normal; color: #666666; font-style: italic; text-align: left; padding-left: 15px; margin-right: 20px; } h4 { font-weight: bold; padding-left: 15px; } .record { margin: 10px; padding: 10px; width: 457px; border: solid 1px #DEDEDE; } .citation { } .heading { font-weight: bold; } .title { font-weight: bold; font-size: 12px; } .citekey { color: #50497A; margin-left: 20px; } .note { } a { color: #0A0AA0; font-weight: bold; text-decoration: none; } @media screen { a:hover { border-bottom: solid 1px gray; } } input.mark { float: left; margin-left: -30px; } input.search { margin-left: 40px; padding: 10px; background-color: transparent; font-size: 10px; font-weight: bold; } input.view{ margin-left: 40px; margin-top: 10px; font-size: 9px; } input.search-button{ margin-left: 20px; font-size: 9px; width: 70px; } select.choose { font-size: 9px; margin-left: 10px; margin-top: 10px; background-color: #E1DD68; } .banner { text-align: center; margin-top: 20px; } @media print { .block { display: none; } } @media screen { .block { margin:0px 6px 12px 6px; padding: 4px; background: #fff; border: 1px solid #999; } .block h3 { background: #ddd; color: #000; margin: -4px -4px 4px -4px; padding: 4px; border-bottom: 1px solid #999; font-size: 11px; } .block ul { margin: 0; padding: 0; list-style-type: none; } .block li { } .block .date { text-align: right; font-size: 9.5pt; font-style: italic; border-bottom: 1px solid #999; } .block .headline { margin-bottom: 10px; } .block a { display: block; padding: 3px; font-size: small; color: #666666; font-weight: normal; } .block a:link, a:visited { text-decoration: none; padding-left: 10px; padding-right: 10px; } .block a:hover { background-color: #ddd; color: #666666; border-bottom: none; } #sidebar input.search-sidebar { margin-left: 10px; width: 120px; } #sidebar input.search-button { margin-top: 5px; margin-bottom: 15px; } } .xmlsrc { margin-top: 20px; margin-bottom: 20px; padding-right: 10px; text-align: right; } .filename { font-family: Courier, monospace; font-size: 120%; } .option { font-family: Courier, monospace; } .classname { text-decoration: underline; } .methodname { text-decoration: underline; } .command { font-weight: bold; } .variablelist { margin-left: 15px; } div.screen { font-family: Courier, monospace; } div.synopsis { margin: 15px; padding-left: 5px; font-family: Courier, monospace; text-align: left; background: #ddd; } .note_title { font-decoration: underline; font-weight: bold; } div.note { margin-top: 10px; margin-bottom: 10px; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; border: 1px solid #203cd8; } .important_title { font-decoration: underline; font-color: red; font-weight: bold; } div.important { margin-top: 10px; margin-bottom: 10px; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; border: 1px solid red; } .example { margin-top: 15px; margin-bottom: 15px; padding-left: 10px; padding-right: 15px; padding-top: 10px; padding-bottom: 10px; text-align: left; background: #fafafa; border: 1px solid #999; } div.example_title { font-size: 14px; font-weight: bold; margin-bottom: 5px; text-decoration: underline; } .figure { margin-top: 15px; margin-bottom: 15px; margin-left: 25px; margin-right: 25px; padding-left: 15px; alignment: center; } .figtitle { font-size: 14px; font-weight: bold; text-decoration: underline; } .variablelist { margin-left: 15px; margin-right: 15px; } #login { padding: 10px; display: block; border: 1px solid #999; background: #fafafa; margin-left: 15px; margin-right: 15px; } |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 21:17:50
|
Update of /cvsroot/exist/eXist-1.0/webapp/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25964/webapp/admin Modified Files: setup.xqm Log Message: Index: setup.xqm =================================================================== RCS file: /cvsroot/exist/eXist-1.0/webapp/admin/setup.xqm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** setup.xqm 2 Jan 2005 18:18:30 -0000 1.5 --- setup.xqm 30 Jan 2005 21:17:41 -0000 1.6 *************** *** 52,55 **** --- 52,59 ---- setup:store-files("/db/xinclude", $dir, ( "xinclude/*.xsl", "xinclude/*.xml"), "text/xml"), + setup:store-files("/db/xinclude", $dir, + "xinclude/*.jpg", "image/jpeg"), + setup:store-files("/db/xinclude", $dir, + "xinclude/*.css", "text/css"), setup:create-collection("/db", "library"), setup:store-files("/db/library", $dir, "*.rdf", "text/xml"), |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:55
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/xmldb Modified Files: LocalCollection.java Log Message: Improved handling of mime-types for resources. Index: LocalCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollection.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** LocalCollection.java 30 Jan 2005 14:17:08 -0000 1.50 --- LocalCollection.java 30 Jan 2005 15:14:17 -0000 1.51 *************** *** 594,597 **** --- 594,598 ---- collection.release(); } + info.getDocument().setMimeType(res.getMimeType()); if (uri != null) { collection.store(broker, info, new InputSource(uri), false); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:34
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/http/webdav/methods Modified Files: Get.java Put.java Head.java Propfind.java Log Message: Improved handling of mime-types for resources. Index: Get.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Get.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Get.java 5 Jan 2005 14:13:10 -0000 1.4 --- Get.java 30 Jan 2005 15:14:18 -0000 1.5 *************** *** 24,29 **** import java.io.IOException; - import java.io.OutputStreamWriter; - import java.io.PrintWriter; import javax.servlet.ServletException; --- 24,27 ---- *************** *** 89,98 **** return; } ! String contentType; ! if(resource.getResourceType() == DocumentImpl.XML_FILE) ! contentType = WebDAV.XML_CONTENT; ! else ! contentType = WebDAV.BINARY_CONTENT; ! response.setContentType(contentType); response.addDateHeader("Last-Modified", resource.getLastModified()); --- 87,91 ---- return; } ! response.setContentType(resource.getMimeType()); response.addDateHeader("Last-Modified", resource.getLastModified()); Index: Head.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Head.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Head.java 5 Jan 2005 14:13:10 -0000 1.6 --- Head.java 30 Jan 2005 15:14:18 -0000 1.7 *************** *** 30,35 **** import org.exist.EXistException; import org.exist.dom.DocumentImpl; - import org.exist.http.webdav.WebDAV; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; --- 30,35 ---- import org.exist.EXistException; + import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; *************** *** 38,42 **** import org.exist.storage.DBBroker; import org.exist.util.Lock; - import org.exist.collections.Collection; /** --- 38,41 ---- *************** *** 73,83 **** response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); return; ! } ! String contentType; ! if(resource.getResourceType() == DocumentImpl.XML_FILE) ! contentType = WebDAV.XML_CONTENT; ! else ! contentType = WebDAV.BINARY_CONTENT; ! response.setContentType(contentType); response.setContentLength(resource.getContentLength()); response.addDateHeader("Last-Modified", resource.getLastModified()); --- 72,77 ---- response.sendError(HttpServletResponse.SC_FORBIDDEN, READ_PERMISSION_DENIED); return; ! } ! response.setContentType(resource.getMimeType()); response.setContentLength(resource.getContentLength()); response.addDateHeader("Last-Modified", resource.getLastModified()); Index: Propfind.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Propfind.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Propfind.java 6 Aug 2004 17:36:36 -0000 1.5 --- Propfind.java 30 Jan 2005 15:14:18 -0000 1.6 *************** *** 383,390 **** if(shouldIncludeProperty(type, searchedProperties, CONTENT_TYPE_PROP)) { ! if(resource.getResourceType() == DocumentImpl.XML_FILE) ! writeSimpleElement(CONTENT_TYPE_PROP, WebDAV.XML_CONTENT, serializer); ! else ! writeSimpleElement(CONTENT_TYPE_PROP, WebDAV.BINARY_CONTENT, serializer); } --- 383,387 ---- if(shouldIncludeProperty(type, searchedProperties, CONTENT_TYPE_PROP)) { ! writeSimpleElement(CONTENT_TYPE_PROP, resource.getMimeType(), serializer); } Index: Put.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Put.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Put.java 23 Jan 2005 20:29:43 -0000 1.7 --- Put.java 30 Jan 2005 15:14:18 -0000 1.8 *************** *** 29,35 **** import java.io.IOException; import java.io.OutputStream; - import java.net.URI; - import java.net.URISyntaxException; - import java.net.URLConnection; import javax.servlet.ServletException; --- 29,32 ---- *************** *** 48,51 **** --- 45,50 ---- import org.exist.util.Lock; import org.exist.util.LockException; + import org.exist.util.MimeTable; + import org.exist.util.MimeType; import org.xml.sax.InputSource; import org.xml.sax.SAXException; *************** *** 95,106 **** return; } if(contentType == null) { ! contentType = URLConnection.guessContentTypeFromName(path); ! } LOG.debug("storing document " + path + "; content-type = " + contentType); ! if(contentType == null || contentType.equalsIgnoreCase("text/xml") || ! contentType.equals("application/xml")) { InputSource is = new InputSource(url); IndexInfo info = collection.validate(broker, path, is); collection.release(); collectionLocked = false; --- 94,112 ---- return; } + MimeType mime; if(contentType == null) { ! mime = MimeTable.getInstance().getContentTypeFor(path); ! if (mime != null) ! contentType = mime.getName(); ! } else { ! mime = MimeTable.getInstance().getContentType(contentType); ! } ! if (mime == null) ! mime = MimeType.BINARY_TYPE; LOG.debug("storing document " + path + "; content-type = " + contentType); ! if(mime.isXMLType()) { InputSource is = new InputSource(url); IndexInfo info = collection.validate(broker, path, is); + info.getDocument().setMimeType(contentType); collection.release(); collectionLocked = false; |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:34
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/http Modified Files: RESTServer.java Log Message: Improved handling of mime-types for resources. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** RESTServer.java 30 Jan 2005 14:17:10 -0000 1.29 --- RESTServer.java 30 Jan 2005 15:14:19 -0000 1.30 *************** *** 58,61 **** --- 58,63 ---- import org.exist.util.Lock; import org.exist.util.LockException; + import org.exist.util.MimeTable; + import org.exist.util.MimeType; import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; *************** *** 480,487 **** } String url = tempFile.toURI().toASCIIString(); ! if (contentType == null ! || contentType.equalsIgnoreCase("text/xml")) { DocumentImpl doc = collection.addDocument(broker, docPath, ! new InputSource(url)); response = new Response(); response.setDescription("Document " + docPath + " stored."); --- 482,499 ---- } String url = tempFile.toURI().toASCIIString(); ! MimeType mime; ! if (contentType != null) ! mime = MimeTable.getInstance().getContentType(contentType); ! else { ! mime = MimeTable.getInstance().getContentTypeFor(docPath); ! if (mime != null) ! contentType = mime.getName(); ! } ! if (mime == null) ! mime = MimeType.BINARY_TYPE; ! ! if (mime.isXMLType()) { DocumentImpl doc = collection.addDocument(broker, docPath, ! new InputSource(url), contentType); response = new Response(); response.setDescription("Document " + docPath + " stored."); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:34
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/soap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/soap Modified Files: AdminSoapBindingImpl.java Log Message: Improved handling of mime-types for resources. Index: AdminSoapBindingImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/soap/AdminSoapBindingImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AdminSoapBindingImpl.java 16 Aug 2004 19:53:47 -0000 1.17 --- AdminSoapBindingImpl.java 30 Jan 2005 15:14:19 -0000 1.18 *************** *** 7,11 **** import javax.xml.parsers.ParserConfigurationException; ! import org.apache.log4j.Category; import org.exist.EXistException; import org.exist.collections.Collection; --- 7,11 ---- import javax.xml.parsers.ParserConfigurationException; ! import org.apache.log4j.Logger; import org.exist.EXistException; import org.exist.collections.Collection; *************** *** 33,37 **** public class AdminSoapBindingImpl implements org.exist.soap.Admin { ! private static Category LOG = Category.getInstance(Admin.class.getName()); private BrokerPool pool; --- 33,37 ---- public class AdminSoapBindingImpl implements org.exist.soap.Admin { ! private static Logger LOG = Logger.getLogger(Admin.class.getName()); private BrokerPool pool; *************** *** 169,173 **** broker, path, ! new InputSource(new ByteArrayInputStream(data))); LOG.debug( "parsing " --- 169,174 ---- broker, path, ! new InputSource(new ByteArrayInputStream(data)), ! "text/xml"); LOG.debug( "parsing " |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:33
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/cluster In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/cluster Modified Files: ClusterCollection.java Log Message: Improved handling of mime-types for resources. Index: ClusterCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/cluster/ClusterCollection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClusterCollection.java 29 Jan 2005 14:57:28 -0000 1.1 --- ClusterCollection.java 30 Jan 2005 15:14:19 -0000 1.2 *************** *** 2,10 **** package org.exist.cluster; import org.exist.EXistException; import org.exist.Indexer; - import org.exist.collections.triggers.TriggerException; import org.exist.collections.Collection; import org.exist.collections.IndexInfo; import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; --- 2,19 ---- package org.exist.cluster; + import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; + import java.io.IOException; + import java.io.InputStream; + import java.io.Reader; + import java.util.Iterator; + import java.util.List; + import java.util.Observer; + import org.exist.EXistException; import org.exist.Indexer; import org.exist.collections.Collection; import org.exist.collections.IndexInfo; + import org.exist.collections.triggers.TriggerException; import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; *************** *** 13,17 **** import org.exist.security.PermissionDeniedException; import org.exist.security.User; - import org.exist.start.*; import org.exist.storage.DBBroker; import org.exist.storage.io.VariableByteInput; --- 22,25 ---- *************** *** 25,33 **** import org.xml.sax.XMLReader; - import java.io.*; - import java.util.Iterator; - import java.util.List; - import java.util.Observer; - /** --- 33,36 ---- *************** *** 328,367 **** } ! public DocumentImpl addDocument(DBBroker broker, String name, String data) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, data); } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, boolean privileged) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, data, privileged); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return collection.addDocument(broker, name, source); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, boolean privileged) throws EXistException, PermissionDeniedException, SAXException, TriggerException, LockException { ! return collection.addDocument(broker, name, source, privileged); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, node); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, boolean privileged) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return collection.addDocument(broker, name, node, privileged); } --- 331,370 ---- } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, String mimeType) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, data, mimeType); } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, String mimeType, boolean privileged) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, data, mimeType, privileged); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, String mimeType) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return collection.addDocument(broker, name, source, mimeType); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, String mimeType, boolean privileged) throws EXistException, PermissionDeniedException, SAXException, TriggerException, LockException { ! return collection.addDocument(broker, name, source, mimeType, privileged); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, String mimeType) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return collection.addDocument(broker, name, node, mimeType); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, String mimeType, boolean privileged) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return collection.addDocument(broker, name, node, mimeType, privileged); } |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:33
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/security In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/security Modified Files: SecurityManager.java Log Message: Improved handling of mime-types for resources. Index: SecurityManager.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/security/SecurityManager.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SecurityManager.java 31 Oct 2004 21:11:08 -0000 1.21 --- SecurityManager.java 30 Jan 2005 15:14:18 -0000 1.22 *************** *** 295,299 **** Collection sysCollection = broker.getCollection(SYSTEM); DocumentImpl doc = ! sysCollection.addDocument(broker, ACL_FILE, buf.toString(), true); doc.setPermissions(0770); broker.saveCollection(doc.getCollection()); --- 295,299 ---- Collection sysCollection = broker.getCollection(SYSTEM); DocumentImpl doc = ! sysCollection.addDocument(broker, ACL_FILE, buf.toString(), "text/xml", true); doc.setPermissions(0770); broker.saveCollection(doc.getCollection()); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:33
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/collections Modified Files: Collection.java Log Message: Improved handling of mime-types for resources. Index: Collection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/Collection.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** Collection.java 29 Jan 2005 15:07:14 -0000 1.68 --- Collection.java 30 Jan 2005 15:14:17 -0000 1.69 *************** *** 1029,1039 **** } ! public DocumentImpl addDocument(DBBroker broker, String name, String data) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return addDocument(broker, name, data, false); } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, boolean privileged) throws EXistException, PermissionDeniedException, TriggerException, SAXException, --- 1029,1039 ---- } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, String mimeType) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return addDocument(broker, name, data, mimeType, false); } ! public DocumentImpl addDocument(DBBroker broker, String name, String data, String mimeType, boolean privileged) throws EXistException, PermissionDeniedException, TriggerException, SAXException, *************** *** 1071,1074 **** --- 1071,1075 ---- } + document.setMimeType(mimeType); if(oldDoc == null) { addDocument(broker, document); *************** *** 1290,1300 **** public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return addDocument(broker, name, source, false); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, boolean privileged) throws EXistException, PermissionDeniedException, SAXException, TriggerException, LockException { --- 1291,1301 ---- public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, String mimeType) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { ! return addDocument(broker, name, source, mimeType, false); } public DocumentImpl addDocument(DBBroker broker, String name, ! InputSource source, String mimeType, boolean privileged) throws EXistException, PermissionDeniedException, SAXException, TriggerException, LockException { *************** *** 1339,1342 **** --- 1340,1344 ---- } + document.setMimeType(mimeType); if(oldDoc == null) { addDocument(broker, document); *************** *** 1363,1373 **** } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return addDocument(broker, name, node, false); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, boolean privileged) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { --- 1365,1375 ---- } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, String mimeType) throws EXistException, PermissionDeniedException, TriggerException, SAXException, LockException { ! return addDocument(broker, name, node, mimeType, false); } ! public DocumentImpl addDocument(DBBroker broker, String name, Node node, String mimeType, boolean privileged) throws EXistException, LockException, PermissionDeniedException, TriggerException, SAXException { *************** *** 1451,1454 **** --- 1453,1457 ---- streamer.serialize(node, true); + document.setMimeType(mimeType); if(oldDoc == null) { addDocument(broker, document); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:31
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/util Modified Files: MimeType.java MimeTable.java Log Message: Improved handling of mime-types for resources. Index: MimeType.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/MimeType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MimeType.java 30 Jan 2005 14:17:09 -0000 1.1 --- MimeType.java 30 Jan 2005 15:14:18 -0000 1.2 *************** *** 28,31 **** --- 28,34 ---- public final static int BINARY = 1; + public final static MimeType BINARY_TYPE = + new MimeType("application/octet-stream", BINARY); + private String name; private String description; *************** *** 50,54 **** public String getXMLDBType() { ! return type == XML ? "XMLResource" : "BinaryResource"; } --- 53,61 ---- public String getXMLDBType() { ! return isXMLType() ? "XMLResource" : "BinaryResource"; ! } ! ! public boolean isXMLType() { ! return type == XML; } Index: MimeTable.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/MimeTable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MimeTable.java 30 Jan 2005 14:17:09 -0000 1.1 --- MimeTable.java 30 Jan 2005 15:14:18 -0000 1.2 *************** *** 90,93 **** --- 90,97 ---- } + public MimeType getContentType(String mimeType) { + return (MimeType) mimeTypes.get(mimeType); + } + public boolean isXMLContent(String fileName) { String ext = getExtension(fileName); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 15:14:31
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5443/src/org/exist/xquery/test Modified Files: LexerTest.java Log Message: Improved handling of mime-types for resources. Index: LexerTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/LexerTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LexerTest.java 16 Nov 2004 15:47:04 -0000 1.5 --- LexerTest.java 30 Jan 2005 15:14:17 -0000 1.6 *************** *** 13,20 **** import org.exist.collections.Collection; import org.exist.collections.triggers.TriggerException; - import org.exist.dom.NodeSet; - import org.exist.xquery.parser.XQueryLexer; - import org.exist.xquery.parser.XQueryParser; - import org.exist.xquery.parser.XQueryTreeParser; import org.exist.security.PermissionDeniedException; import org.exist.security.User; --- 13,16 ---- *************** *** 26,29 **** --- 22,28 ---- import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; + import org.exist.xquery.parser.XQueryLexer; + import org.exist.xquery.parser.XQueryParser; + import org.exist.xquery.parser.XQueryTreeParser; import org.exist.xquery.value.Sequence; import org.xml.sax.SAXException; *************** *** 91,95 **** broker = pool.get(user); Collection collection = broker.getCollection("/db/test"); ! collection.addDocument(broker, "test.xml", xml); // parse the query into the internal syntax tree --- 90,94 ---- broker = pool.get(user); Collection collection = broker.getCollection("/db/test"); ! collection.addDocument(broker, "test.xml", xml, "text/xml"); // parse the query into the internal syntax tree |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:22:01
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27358/src/org/exist/client Modified Files: InteractiveClient.java Log Message: Improved handling of mime-types for resources. Index: InteractiveClient.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/InteractiveClient.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** InteractiveClient.java 30 Jan 2005 14:17:09 -0000 1.43 --- InteractiveClient.java 30 Jan 2005 14:21:33 -0000 1.44 *************** *** 84,88 **** import org.exist.util.ProgressBar; import org.exist.util.ProgressIndicator; - import org.exist.util.XMLFilenameFilter; import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; --- 84,87 ---- *************** *** 278,284 **** protected Properties properties; - protected String[] xmlSuffixes; - protected String[] binarySuffixes; - protected String[] resources = null; protected ResourceSet result = null; --- 277,280 ---- *************** *** 1744,1749 **** } catch (IOException ioe) { } - xmlSuffixes = splitProperty("suffixes.xml"); - binarySuffixes = splitProperty("suffixes.binary"); // parse command-line options --- 1740,1743 ---- *************** *** 2368,2384 **** } - private String[] splitProperty(String key) { - String value = properties.getProperty(key); - if(value == null) - return new String[0]; - StringTokenizer tok = new StringTokenizer(value, ", "); - String values[] = new String[tok.countTokens()]; - for(int i = 0; tok.hasMoreTokens(); i++) { - values[i] = tok.nextToken(); - } - Arrays.sort(values); - return values; - } - private class CollectionCompleter implements ReadlineCompleter { --- 2362,2365 ---- |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:21:25
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27304 Modified Files: client.properties Log Message: Improved handling of mime-types for resources. Index: client.properties =================================================================== RCS file: /cvsroot/exist/eXist-1.0/client.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** client.properties 18 Jun 2004 08:53:14 -0000 1.18 --- client.properties 30 Jan 2005 14:21:11 -0000 1.19 *************** *** 38,45 **** # possible values are "none", "both", "elements", "attributes" highlight-matches=none - - # files with the following suffixes are stored as XML files - suffixes.xml=xml,xsl,xsd,svg,rdf,vscml,mods,xmi,xconf - - # files with the following suffixes are stored as binary resources - suffixes.binary=xq,xql,gif,jpg,png,css --- 38,39 ---- |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:18:57
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26676 Modified Files: build.xml Added Files: mime-types.xml Log Message: Improved handling of mime-types for resources. Index: build.xml =================================================================== RCS file: /cvsroot/exist/eXist-1.0/build.xml,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** build.xml 29 Jan 2005 21:45:50 -0000 1.74 --- build.xml 30 Jan 2005 14:18:49 -0000 1.75 *************** *** 229,232 **** --- 229,234 ---- <copy file="${src}/org/exist/system.properties" todir="${build.classes}/org/exist" filtering="true"/> + <copy file="${src}/org/exist/util/mime-types.xml" + todir="${build.classes}/org/exist/util"/> <echo message="Creating exist.jar ..."/> --- NEW FILE: mime-types.xml --- <?xml version="1.0" encoding="UTF-8"?> <!-- ====================================================== This file lists all mime types known to eXist. When storing a document with the Java client, the type of the resource is looked up here. A resource will be stored as an XML or a binary resource, depending on the "type" attribute of the corresponding mime-type entry. ======================================================= --> <mime-types> <!-- Mime types stored as XML --> <mime-type name="text/xml" type="xml"> <description>XML document</description> <extensions>.xml,.xsl,.xsd,.mods,.xmi,.xconf</extensions> </mime-type> <mime-type name="application/xml" type="xml"> <description>XML document</description> <extensions>.xml</extensions> </mime-type> <mime-type name="application/rdf+xml" type="xml"> <description>RDF document</description> <extensions>.rdf</extensions> </mime-type> <mime-type name="application/xhtml+xml" type="xml"> <description>XHTML document</description> <extensions>.xht, .xhtml</extensions> </mime-type> <mime-type name="text/html" type="xml"> <description>HTML document</description> <extensions>.html,.htm</extensions> </mime-type> <mime-type name="image/svg+xml" type="xml"> <description>SVG image</description> <extensions>.svg,.svgz</extensions> </mime-type> <!-- Binary mime types --> <mime-type name="application/xquery" type="binary"> <description>XQuery script</description> <extensions>.xq,.xql,.xqm,.xquery</extensions> </mime-type> <mime-type name="application/octet-stream" type="binary"> <description>Generic binary stream</description> <extensions>.jar,.exe,.o</extensions> </mime-type> <mime-type name="application/zip" type="binary"> <description>ZIP archive</description> <extensions>.zip</extensions> </mime-type> <mime-type name="text/plain" type="binary"> <description>Plain text</description> <extensions>.txt,.text,.java</extensions> </mime-type> <mime-type name="text/css" type="binary"> <description>CSS stylesheet</description> <extensions>.css</extensions> </mime-type> <mime-type name="image/gif" type="binary"> <description>GIF image</description> <extensions>.gif</extensions> </mime-type> <mime-type name="image/jpeg" type="binary"> <description>JPEG image</description> <extensions>.jpg,.jpeg</extensions> </mime-type> <mime-type name="image/x-portable-bitmap" type="binary"> <description>PBM Bitmap Format</description> <extensions>.pbm</extensions> </mime-type> </mime-types> |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:17:22
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26168/src/org/exist/xmldb Modified Files: LocalCollection.java EXistResource.java AbstractEXistResource.java LocalBinaryResource.java Log Message: Improved handling of mime-types for resources. Index: LocalBinaryResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalBinaryResource.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LocalBinaryResource.java 23 Jan 2005 20:29:41 -0000 1.6 --- LocalBinaryResource.java 30 Jan 2005 14:17:08 -0000 1.7 *************** *** 54,58 **** */ public LocalBinaryResource(User user, BrokerPool pool, LocalCollection collection, String docId) { ! super(user, pool, collection, docId, "application/octet-stream"); } --- 54,58 ---- */ public LocalBinaryResource(User user, BrokerPool pool, LocalCollection collection, String docId) { ! super(user, pool, collection, docId, null); } *************** *** 141,144 **** --- 141,146 ---- */ public Date getCreationTime() throws XMLDBException { + if (isNewResource) + throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored"); DBBroker broker = null; try { *************** *** 161,164 **** --- 163,168 ---- */ public Date getLastModificationTime() throws XMLDBException { + if (isNewResource) + throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored"); DBBroker broker = null; try { *************** *** 177,184 **** --- 181,213 ---- } + /* (non-Javadoc) + * @see org.exist.xmldb.AbstractEXistResource#getMimeType() + */ + public String getMimeType() throws XMLDBException { + if (isNewResource) + return mimeType; + DBBroker broker = null; + try { + broker = pool.get(user); + BinaryDocument blob = (BinaryDocument)getDocument(broker, false); + if (!blob.getPermissions().validate(user, Permission.READ)) + throw new XMLDBException( + ErrorCodes.PERMISSION_DENIED, + "permission denied to read resource"); + mimeType = blob.getMimeType(); + return mimeType; + } catch (EXistException e) { + throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e); + } finally { + pool.release(broker); + } + } + /* (non-Javadoc) * @see org.exist.xmldb.EXistResource#getPermissions() */ public Permission getPermissions() throws XMLDBException { + if (isNewResource) + throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored"); DBBroker broker = null; try { *************** *** 197,200 **** --- 226,231 ---- */ public int getContentLength() throws XMLDBException { + if (isNewResource) + throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored"); DBBroker broker = null; try { Index: LocalCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollection.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** LocalCollection.java 23 Jan 2005 20:29:41 -0000 1.49 --- LocalCollection.java 30 Jan 2005 14:17:08 -0000 1.50 *************** *** 249,252 **** --- 249,253 ---- ErrorCodes.INVALID_RESOURCE, "unknown resource type: " + type); + ((AbstractEXistResource)r).isNewResource = true; return r; } *************** *** 536,539 **** --- 537,541 ---- ErrorCodes.UNKNOWN_RESOURCE_TYPE, "unknown resource type: " + resource.getResourceType()); + ((AbstractEXistResource)resource).isNewResource = false; needsSync = true; } Index: EXistResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/EXistResource.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EXistResource.java 23 Jan 2005 20:29:41 -0000 1.6 --- EXistResource.java 30 Jan 2005 14:17:08 -0000 1.7 *************** *** 50,53 **** void setMimeType(String mime); ! String getMimeType(); } --- 50,53 ---- void setMimeType(String mime); ! String getMimeType() throws XMLDBException; } Index: AbstractEXistResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/AbstractEXistResource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractEXistResource.java 23 Jan 2005 20:29:41 -0000 1.3 --- AbstractEXistResource.java 30 Jan 2005 14:17:08 -0000 1.4 *************** *** 45,48 **** --- 45,49 ---- protected String docId = null; protected String mimeType = null; + protected boolean isNewResource = false; public AbstractEXistResource(User user, BrokerPool pool, LocalCollection parent, String docId, String mimeType) { *************** *** 81,85 **** } ! public String getMimeType() { return mimeType; } --- 82,86 ---- } ! public String getMimeType() throws XMLDBException { return mimeType; } |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:17:22
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26168/src/org/exist/dom Modified Files: DocumentImpl.java BinaryDocument.java Log Message: Improved handling of mime-types for resources. Index: BinaryDocument.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/BinaryDocument.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BinaryDocument.java 30 Jan 2005 10:13:36 -0000 1.7 --- BinaryDocument.java 30 Jan 2005 14:17:10 -0000 1.8 *************** *** 46,58 **** private long pageNr = -1; - - private String mimeType = "application/octet-stream"; public BinaryDocument(DBBroker broker, Collection collection) { super(broker, collection); } public BinaryDocument(DBBroker broker, String docName, Collection collection) { super(broker, docName, collection); } --- 46,58 ---- private long pageNr = -1; public BinaryDocument(DBBroker broker, Collection collection) { super(broker, collection); + this.mimeType = "application/octet-stream"; } public BinaryDocument(DBBroker broker, String docName, Collection collection) { super(broker, docName, collection); + this.mimeType = "application/octet-stream"; } *************** *** 63,75 **** return BINARY_FILE; } - - public void setMimeType(String type) { - this.mimeType = type; - } - - public String getMimeType() { - checkAvail(); - return mimeType; - } public void setPage(long page) { --- 63,66 ---- Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentImpl.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** DocumentImpl.java 28 Jan 2005 16:57:37 -0000 1.67 --- DocumentImpl.java 30 Jan 2005 14:17:10 -0000 1.68 *************** *** 92,95 **** --- 92,97 ---- protected String fileName = null; + protected String mimeType = "text/xml"; + // the creation time of this document protected long created = 0; *************** *** 206,212 **** return XML_FILE; } ! public String getMimeType() { ! return "text/xml"; } --- 208,220 ---- return XML_FILE; } ! ! public void setMimeType(String type) { ! if (type != null) ! this.mimeType = type; ! } ! public String getMimeType() { ! checkAvail(); ! return mimeType; } *************** *** 730,733 **** --- 738,742 ---- ostream.writeLong(created); ostream.writeLong(lastModified); + ostream.writeUTF(mimeType); ostream.writeInt(pageCount); final byte[] data = ostream.toByteArray(); *************** *** 757,760 **** --- 766,770 ---- created = istream.readLong(); lastModified = istream.readLong(); + mimeType = istream.readUTF(); if(istream.available() > 0) pageCount = istream.readInt(); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:17:22
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26168/src/org/exist/util Added Files: MimeType.java MimeTable.java mime-types.xml Removed Files: MutableStringTokenizer.java Log Message: Improved handling of mime-types for resources. --- NEW FILE: MimeType.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: MimeType.java,v 1.1 2005/01/30 14:17:09 wolfgang_m Exp $ */ package org.exist.util; public class MimeType { public final static int XML = 0; public final static int BINARY = 1; private String name; private String description; private int type = MimeType.XML; public MimeType(String name, int type) { this.name = name; this.type = type; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getName() { return name; } public int getType() { return type; } public String getXMLDBType() { return type == XML ? "XMLResource" : "BinaryResource"; } public String toString() { return name + ": " + description; } } --- NEW FILE: MimeTable.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: MimeTable.java,v 1.1 2005/01/30 14:17:09 wolfgang_m Exp $ */ package org.exist.util; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.apache.log4j.Logger; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; /** * Global table of mime types. This singleton class maintains a list * of mime types known to the system. It is used to look up the * mime type for a specific file extension and to check if a file * is an XML or binary resource. * * The mime type table is read from a file "mime-types.xml", * which should reside in the directory identified by the system * property "exist.home". If no such file is found, the class tries * to load the default map from the org.exist.util package via the * class loader. * * @author wolf */ public class MimeTable { private static final String FILE_LOAD_FAILED_ERR = "Failed to load mime-type table from "; private static final String LOAD_FAILED_ERR = "Failed to load mime-type table from class loader"; private static final String MIME_TYPES_XML_DEFAULT = "org/exist/util/mime-types.xml"; private static final String MIME_TYPES_XML = "mime-types.xml"; private final static Logger LOG = Logger.getLogger(MimeTable.class); private static MimeTable instance = null; /** * Returns the singleton. * * @return */ public static MimeTable getInstance() { if (instance == null) instance = new MimeTable(); return instance; } private Map mimeTypes = new TreeMap(); private Map extensions = new TreeMap(); public MimeTable() { load(); } public MimeType getContentTypeFor(String fileName) { String ext = getExtension(fileName); return ext == null ? null : (MimeType) extensions.get(ext); } public boolean isXMLContent(String fileName) { String ext = getExtension(fileName); if (ext == null) return false; MimeType type = (MimeType) extensions.get(ext); if (type == null) return false; return type.getType() == MimeType.XML; } private String getExtension(String fileName) { File f = new File(fileName); fileName = f.getName(); int p = fileName.lastIndexOf('.'); if (p < 0 || p + 1 == fileName.length()) return null; return fileName.substring(p); } private void load() { boolean loaded = false; String home = System.getProperty("exist.home"); if (home != null) { File f = new File(home + File.separatorChar + MIME_TYPES_XML); if (f.canRead()) { try { LOG.debug("Loading mime table from file " + f.getAbsolutePath()); loadMimeTypes(new FileInputStream(f)); loaded = true; } catch (FileNotFoundException e) { LOG.warn(FILE_LOAD_FAILED_ERR + f.getAbsolutePath(), e); } catch (ParserConfigurationException e) { LOG.warn(FILE_LOAD_FAILED_ERR + f.getAbsolutePath(), e); } catch (SAXException e) { LOG.warn(FILE_LOAD_FAILED_ERR + f.getAbsolutePath(), e); } catch (IOException e) { LOG.warn(FILE_LOAD_FAILED_ERR + f.getAbsolutePath(), e); } } } if (!loaded) { LOG.debug("Loading mime table"); ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream is = cl.getResourceAsStream(MIME_TYPES_XML_DEFAULT); if (is == null) { LOG.warn(LOAD_FAILED_ERR); } try { loadMimeTypes(is); } catch (ParserConfigurationException e) { LOG.warn(LOAD_FAILED_ERR, e); } catch (SAXException e) { LOG.warn(LOAD_FAILED_ERR, e); } catch (IOException e) { LOG.warn(LOAD_FAILED_ERR, e); } } } /** * @param stream * @throws SAXException * @throws ParserConfigurationException * @throws IOException */ private void loadMimeTypes(InputStream stream) throws ParserConfigurationException, SAXException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); InputSource src = new InputSource(stream); SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(new MimeTableHandler()); reader.parse(new InputSource(stream)); } private class MimeTableHandler extends DefaultHandler { private static final String EXTENSIONS = "extensions"; private static final String DESCRIPTION = "description"; private static final String MIME_TYPE = "mime-type"; private MimeType mime = null; private FastStringBuffer charBuf = new FastStringBuffer(6, 15, 5); /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (MIME_TYPE.equals(qName)) { String name = attributes.getValue("name"); if (name == null || name.length() == 0) { LOG.warn("No name specified for mime-type"); return; } int type = MimeType.BINARY; String typeAttr = attributes.getValue("type"); if (typeAttr != null && "xml".equals(typeAttr)) type = MimeType.XML; mime = new MimeType(name, type); mimeTypes.put(name, mime); } charBuf.setLength(0); } /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String uri, String localName, String qName) throws SAXException { if (MIME_TYPE.equals(qName)) { mime = null; } else if (DESCRIPTION.equals(qName)) { if (mime != null) { String description = charBuf.getNormalizedString(FastStringBuffer.SUPPRESS_BOTH); mime.setDescription(description); } } else if (EXTENSIONS.equals(qName)) { if (mime != null) { String extList = charBuf.getNormalizedString(FastStringBuffer.SUPPRESS_BOTH); StringTokenizer tok = new StringTokenizer(extList, ", "); while (tok.hasMoreTokens()) { String ext = tok.nextToken(); if (!extensions.containsKey(ext)) extensions.put(ext, mime); } } } } /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ public void characters(char[] ch, int start, int length) throws SAXException { charBuf.append(ch, start, length); } } public static void main(String[] args) { MimeTable table = MimeTable.getInstance(); MimeType type = table.getContentTypeFor("samples/xquery/fibo.svg"); if (type == null) { System.out.println("Not found!"); } else { System.out.println(type.getName()); System.out.println(type.getDescription()); } } } --- MutableStringTokenizer.java DELETED --- --- NEW FILE: mime-types.xml --- <?xml version="1.0" encoding="UTF-8"?> <!-- ====================================================== This file lists all mime types known to eXist. When storing a document with the Java client, the type of the resource is looked up here. A resource will be stored as an XML or a binary resource, depending on the "type" attribute of the corresponding mime-type entry. ======================================================= --> <mime-types> <!-- Mime types stored as XML --> <mime-type name="text/xml" type="xml"> <description>XML document</description> <extensions>.xml,.xsl,.xsd,.mods,.xmi,.xconf</extensions> </mime-type> <mime-type name="application/xml" type="xml"> <description>XML document</description> <extensions>.xml</extensions> </mime-type> <mime-type name="application/rdf+xml" type="xml"> <description>RDF document</description> <extensions>.rdf</extensions> </mime-type> <mime-type name="application/xhtml+xml" type="xml"> <description>XHTML document</description> <extensions>.xht, .xhtml</extensions> </mime-type> <mime-type name="text/html" type="xml"> <description>HTML document</description> <extensions>.html,.htm</extensions> </mime-type> <mime-type name="image/svg+xml" type="xml"> <description>SVG image</description> <extensions>.svg,.svgz</extensions> </mime-type> <!-- Binary mime types --> <mime-type name="application/xquery" type="binary"> <description>XQuery script</description> <extensions>.xq,.xql,.xqm,.xquery</extensions> </mime-type> <mime-type name="application/octet-stream" type="binary"> <description>Generic binary stream</description> <extensions>.jar,.exe,.o</extensions> </mime-type> <mime-type name="application/zip" type="binary"> <description>ZIP archive</description> <extensions>.zip</extensions> </mime-type> <mime-type name="text/plain" type="binary"> <description>Plain text</description> <extensions>.txt,.text,.java</extensions> </mime-type> <mime-type name="text/css" type="binary"> <description>CSS stylesheet</description> <extensions>.css</extensions> </mime-type> <mime-type name="image/gif" type="binary"> <description>GIF image</description> <extensions>.gif</extensions> </mime-type> <mime-type name="image/jpeg" type="binary"> <description>JPEG image</description> <extensions>.jpg,.jpeg</extensions> </mime-type> <mime-type name="image/x-portable-bitmap" type="binary"> <description>PBM Bitmap Format</description> <extensions>.pbm</extensions> </mime-type> </mime-types> |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:17:22
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26168/src/org/exist/http Modified Files: RESTServer.java Log Message: Improved handling of mime-types for resources. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** RESTServer.java 23 Jan 2005 20:29:45 -0000 1.28 --- RESTServer.java 30 Jan 2005 14:17:10 -0000 1.29 *************** *** 56,59 **** --- 56,60 ---- import org.exist.storage.serializers.EXistOutputKeys; import org.exist.storage.serializers.Serializer; + import org.exist.util.Lock; import org.exist.util.LockException; import org.exist.util.serializer.SAXSerializer; *************** *** 107,112 **** /** ! * Handle GET request. In the simplest case just returns the document ! * or binary resource specified in the path. If the path leads to a collection, * a listing of the collection contents is returned. * --- 108,113 ---- /** ! * Handle GET request. In the simplest case just returns the document or ! * binary resource specified in the path. If the path leads to a collection, * a listing of the collection contents is returned. * *************** *** 114,129 **** * * <ul> ! * <li>_xpath or _query: if specified, the given query is executed on the current ! * resource or collection.</li> * ! * <li>_howmany: defines how many items from the query result will be returned.</li> * * <li>_start: a start offset into the result set.</li> * ! * <li>_wrap: if set to "yes", the query results will be wrapped into a exist:result element.</li> * ! * <li>_indent: if set to "yes", the returned XML will be pretty-printed.</li> * ! * <li>_xsl: an URI pointing to an XSL stylesheet that will be applied to the returned XML.</li> * * @param broker --- 115,134 ---- * * <ul> ! * <li>_xpath or _query: if specified, the given query is executed on the ! * current resource or collection.</li> * ! * <li>_howmany: defines how many items from the query result will be ! * returned.</li> * * <li>_start: a start offset into the result set.</li> * ! * <li>_wrap: if set to "yes", the query results will be wrapped into a ! * exist:result element.</li> * ! * <li>_indent: if set to "yes", the returned XML will be pretty-printed. ! * </li> * ! * <li>_xsl: an URI pointing to an XSL stylesheet that will be applied to ! * the returned XML.</li> * * @param broker *************** *** 138,144 **** throws BadRequestException, PermissionDeniedException, NotFoundException { ! // Process special parameters ! int howmany = 10; int start = 1; --- 143,149 ---- throws BadRequestException, PermissionDeniedException, NotFoundException { ! // Process special parameters ! int howmany = 10; int start = 1; *************** *** 189,256 **** else encoding = "UTF-8"; ! // Process the request Response response = new Response(); ! if (query != null) { ! // query parameter specified ! try { ! response.setContent(search(broker, query, path, howmany, start, ! outputProperties, wrap)); ! } catch (XPathException e) { ! response.setContent(formatXPathException(query, e)); ! response.setContentType("text/html"); ! response.setResponseCode(HttpServerConnection.HTTP_BAD_REQUEST); ! return response; } ! } else { ! // no query parameter: try to load a document from the specified path ! DocumentImpl d = (DocumentImpl) broker.getDocument(path); ! if (d == null) { ! // no document: check if path points to a collection ! Collection collection = broker.getCollection(path); ! if (collection != null) { ! if (!collection.getPermissions().validate(broker.getUser(), ! Permission.READ)) ! throw new PermissionDeniedException( ! "Not allowed to read collection"); ! // return a listing of the collection contents ! response = new Response(printCollection(broker, collection)); ! } else { ! throw new NotFoundException("Document " + path ! + " not found"); } } else { ! // document found: serialize it ! if (!d.getPermissions().validate(broker.getUser(), ! Permission.READ)) ! throw new PermissionDeniedException( ! "Not allowed to read resource"); ! if (d.getResourceType() == DocumentImpl.BINARY_FILE) { ! // binary resource ! response.setContentType(d.getMimeType()); ! response.setContent(broker ! .getBinaryResourceData((BinaryDocument) d)); } else { ! // xml resource ! Serializer serializer = broker.getSerializer(); ! serializer.reset(); ! if (stylesheet != null) { ! serializer.setStylesheet(d, stylesheet); ! response.setContentType("text/html"); ! } ! try { ! serializer.setProperties(outputProperties); ! response.setContent(serializer.serialize(d)); ! if (serializer.isStylesheetApplied()) response.setContentType("text/html"); ! } catch (SAXException saxe) { ! LOG.warn(saxe); ! throw new BadRequestException( ! "Error while serializing XML: " ! + saxe.getMessage()); } } } } return response; --- 194,278 ---- else encoding = "UTF-8"; ! // Process the request Response response = new Response(); ! ! DocumentImpl resource = null; ! try { ! // first, check if path leads to an XQuery resource ! resource = (DocumentImpl) broker.openDocument(path, Lock.READ_LOCK); ! if (resource != null) { ! if (resource.getResourceType() == DocumentImpl.BINARY_FILE && ! "application/xquery".equals(resource.getMimeType())) ! LOG.debug("XQUERY FOUND!!!!"); } ! if (query != null) { ! // query parameter specified ! try { ! response.setContent(search(broker, query, path, howmany, ! start, outputProperties, wrap)); ! } catch (XPathException e) { ! response.setContent(formatXPathException(query, e)); ! response.setContentType("text/html"); ! response ! .setResponseCode(HttpServerConnection.HTTP_BAD_REQUEST); ! return response; } } else { ! // no query parameter: try to load a document from the specified ! // path ! if (resource == null) { ! // no document: check if path points to a collection ! Collection collection = broker.getCollection(path); ! if (collection != null) { ! if (!collection.getPermissions().validate( ! broker.getUser(), Permission.READ)) ! throw new PermissionDeniedException( ! "Not allowed to read collection"); ! // return a listing of the collection contents ! response = new Response(printCollection(broker, ! collection)); ! } else { ! throw new NotFoundException("Document " + path ! + " not found"); ! } } else { ! // document found: serialize it ! if (!resource.getPermissions().validate(broker.getUser(), ! Permission.READ)) ! throw new PermissionDeniedException( ! "Not allowed to read resource"); ! if (resource.getResourceType() == DocumentImpl.BINARY_FILE) { ! // binary resource ! response.setContentType(resource.getMimeType()); ! response ! .setContent(broker ! .getBinaryResourceData((BinaryDocument) resource)); ! } else { ! // xml resource ! Serializer serializer = broker.getSerializer(); ! serializer.reset(); ! if (stylesheet != null) { ! serializer.setStylesheet(resource, stylesheet); response.setContentType("text/html"); ! } ! try { ! serializer.setProperties(outputProperties); ! response.setContent(serializer.serialize(resource)); ! if (serializer.isStylesheetApplied()) ! response.setContentType("text/html"); ! } catch (SAXException saxe) { ! LOG.warn(saxe); ! throw new BadRequestException( ! "Error while serializing XML: " ! + saxe.getMessage()); ! } } } } + } finally { + if (resource != null) + resource.getUpdateLock().release(Lock.READ_LOCK); } return response; |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 14:17:21
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26168/src/org/exist/client Modified Files: InteractiveClient.java ResourcePropertyDialog.java ClientFrame.java Log Message: Improved handling of mime-types for resources. Index: ClientFrame.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/ClientFrame.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ClientFrame.java 4 Nov 2004 22:04:11 -0000 1.28 --- ClientFrame.java 30 Jan 2005 14:17:09 -0000 1.29 *************** *** 48,52 **** import java.io.StringWriter; import java.net.URL; - import java.util.Arrays; import java.util.Date; import java.util.Enumeration; --- 48,51 ---- *************** *** 97,100 **** --- 96,100 ---- import org.exist.security.User; import org.exist.storage.serializers.EXistOutputKeys; + import org.exist.util.MimeTable; import org.exist.xmldb.CollectionImpl; import org.exist.xmldb.CollectionManagementServiceImpl; *************** *** 1078,1081 **** --- 1078,1082 ---- Date created = new Date(); Date modified = null; + String mimeType = null; if (fileman.getSelectedRowCount() == 1) { int row = fileman.getSelectedRow(); *************** *** 1091,1094 **** --- 1092,1096 ---- created = ((EXistResource) res).getCreationTime(); modified = ((EXistResource) res).getLastModificationTime(); + mimeType = ((EXistResource) res).getMimeType(); perm = service.getPermissions(res); } *************** *** 1098,1102 **** } ResourcePropertyDialog dialog = new ResourcePropertyDialog(this, ! service, name, perm, created, modified); dialog.setVisible(true); if (dialog.getResult() == ResourcePropertyDialog.APPLY_OPTION) { --- 1100,1104 ---- } ResourcePropertyDialog dialog = new ResourcePropertyDialog(this, ! service, name, perm, created, modified, mimeType); dialog.setVisible(true); if (dialog.getResult() == ResourcePropertyDialog.APPLY_OPTION) { *************** *** 1591,1595 **** class BinaryFileFilter extends FileFilter { ! /* (non-Javadoc) * @see javax.swing.filechooser.FileFilter#getDescription() --- 1593,1597 ---- class BinaryFileFilter extends FileFilter { ! /* (non-Javadoc) * @see javax.swing.filechooser.FileFilter#getDescription() *************** *** 1605,1619 **** if(f.isDirectory()) return true; ! String name = f.getName(); ! int p = name.lastIndexOf('.'); ! if(p < 0 || p + 1 == name.length()) ! return false; ! name = name.substring(p + 1); ! return Arrays.binarySearch(client.binarySuffixes, name) > -1; } } class XMLFileFilter extends FileFilter { ! /* (non-Javadoc) * @see javax.swing.filechooser.FileFilter#getDescription() --- 1607,1616 ---- if(f.isDirectory()) return true; ! return !MimeTable.getInstance().isXMLContent(f.getName()); } } class XMLFileFilter extends FileFilter { ! /* (non-Javadoc) * @see javax.swing.filechooser.FileFilter#getDescription() *************** *** 1629,1638 **** if(f.isDirectory()) return true; ! String name = f.getName(); ! int p = name.lastIndexOf('.'); ! if(p < 0 || p + 1 == name.length()) ! return false; ! name = name.substring(p + 1); ! return Arrays.binarySearch(client.xmlSuffixes, name) > -1; } } --- 1626,1630 ---- if(f.isDirectory()) return true; ! return MimeTable.getInstance().isXMLContent(f.getName()); } } Index: InteractiveClient.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/InteractiveClient.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** InteractiveClient.java 23 Jan 2005 20:29:44 -0000 1.42 --- InteractiveClient.java 30 Jan 2005 14:17:09 -0000 1.43 *************** *** 44,48 **** import java.io.UnsupportedEncodingException; import java.io.Writer; - import java.net.URLConnection; import java.nio.charset.Charset; import java.util.ArrayList; --- 44,47 ---- *************** *** 80,83 **** --- 79,84 ---- import org.exist.util.CollectionScanner; import org.exist.util.DirectoryScanner; + import org.exist.util.MimeTable; + import org.exist.util.MimeType; import org.exist.util.Occurrences; import org.exist.util.ProgressBar; *************** *** 1379,1385 **** --- 1380,1388 ---- File file = new File(fileName); if (file.canRead()) { + MimeType mime = MimeTable.getInstance().getContentTypeFor(file.getName()); BinaryResource resource = (BinaryResource) current.createResource( file.getName(), "BinaryResource"); resource.setContent(file); + ((EXistResource)resource).setMimeType(mime == null ? "application/octet-stream" : mime.getName()); current.storeResource(resource); } *************** *** 1407,1411 **** Resource document; CollectionManagementService mgtService; ! String next, resourceType; for (int i = 0; i < temp.length; i++) { next = base + '/' + temp[i].getName(); --- 1410,1415 ---- Resource document; CollectionManagementService mgtService; ! String next; ! MimeType mimeType; for (int i = 0; i < temp.length; i++) { next = base + '/' + temp[i].getName(); *************** *** 1427,1432 **** } else { long start1 = System.currentTimeMillis(); ! resourceType = getResourceType(temp[i].getName()); ! if(resourceType == null) messageln("File " + temp[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); --- 1431,1436 ---- } else { long start1 = System.currentTimeMillis(); ! mimeType = MimeTable.getInstance().getContentTypeFor(temp[i].getName()); ! if(mimeType == null) messageln("File " + temp[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); *************** *** 1435,1440 **** + " of " + temp.length + ") " + "..."); document = collection.createResource(temp[i] ! .getName(), resourceType); document.setContent(temp[i]); collection.storeResource(document); ++filesCount; --- 1439,1445 ---- + " of " + temp.length + ") " + "..."); document = collection.createResource(temp[i] ! .getName(), mimeType.getXMLDBType()); document.setContent(temp[i]); + ((EXistResource)document).setMimeType(mimeType.getName()); collection.storeResource(document); ++filesCount; *************** *** 1477,1481 **** return result; } else ! files = file.listFiles(new XMLFilenameFilter()); } else { files = new File[1]; --- 1482,1486 ---- return result; } else ! files = file.listFiles(); } else { files = new File[1]; *************** *** 1488,1504 **** long start0 = System.currentTimeMillis(); long bytes = 0; ! String resourceType; for (int i = 0; i < files.length; i++) { start = System.currentTimeMillis(); ! resourceType = getResourceType(files[i].getName()); ! if(resourceType == null) messageln("File " + files[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); else { document = current.createResource(files[i].getName(), ! resourceType); message("storing document " + files[i].getName() + " (" + (i + 1) + " of " + files.length + ") ..."); document.setContent(files[i]); current.storeResource(document); messageln("done."); --- 1493,1510 ---- long start0 = System.currentTimeMillis(); long bytes = 0; ! MimeType mimeType; for (int i = 0; i < files.length; i++) { start = System.currentTimeMillis(); ! mimeType = MimeTable.getInstance().getContentTypeFor(files[i].getName()); ! if(mimeType == null) messageln("File " + files[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); else { document = current.createResource(files[i].getName(), ! mimeType.getXMLDBType()); message("storing document " + files[i].getName() + " (" + (i + 1) + " of " + files.length + ") ..."); document.setContent(files[i]); + ((EXistResource)document).setMimeType(mimeType.getName()); current.storeResource(document); messageln("done."); *************** *** 1523,1527 **** upload.setTotalSize(calculateFileSizes(files)); long totalSize = 0; ! String resourceType, mimeType; for (int i = 0; i < files.length; i++) { if (files[i].canRead()) { --- 1529,1534 ---- upload.setTotalSize(calculateFileSizes(files)); long totalSize = 0; ! String resourceType; ! MimeType mimeType; for (int i = 0; i < files.length; i++) { if (files[i].canRead()) { *************** *** 1536,1554 **** upload.setCurrentSize(files[i].length()); try { ! mimeType = URLConnection.guessContentTypeFromName(files[i].getName()); ! System.out.println("Guessed mime type = " + mimeType); ! resourceType = getResourceType(files[i].getName()); ! if(resourceType == null) { ! if(mimeType.equals("text/xml") || mimeType.equals("application/xml")) ! resourceType = "XMLResource"; ! else ! resourceType = "BinaryResource"; ! } else { ! document = current.createResource( ! files[i].getName(), resourceType); ! document.setContent(files[i]); ! ((EXistResource)document).setMimeType(mimeType); ! current.storeResource(document); ! } totalSize += files[i].length(); upload.setStoredSize(totalSize); --- 1543,1553 ---- upload.setCurrentSize(files[i].length()); try { ! mimeType = MimeTable.getInstance().getContentTypeFor(files[i].getName()); ! resourceType = mimeType.getType() == MimeType.XML ? "XMLResource" : "BinaryResource"; ! document = current.createResource( ! files[i].getName(), resourceType); ! ((EXistResource)document).setMimeType(mimeType.getName()); ! document.setContent(files[i]); ! current.storeResource(document); totalSize += files[i].length(); upload.setStoredSize(totalSize); *************** *** 1587,1591 **** Resource document; CollectionManagementService mgtService; ! String next, resourceType; for (int i = 0; i < temp.length; i++) { next = base + '/' + temp[i].getName(); --- 1586,1591 ---- Resource document; CollectionManagementService mgtService; ! String next; ! MimeType mimeType; for (int i = 0; i < temp.length; i++) { next = base + '/' + temp[i].getName(); *************** *** 1611,1621 **** upload.setCurrentSize(temp[i].length()); ! resourceType = getResourceType(temp[i].getName()); ! if(resourceType == null) upload.showMessage("File " + temp[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); else { document = collection.createResource(temp[i] ! .getName(), resourceType); document.setContent(temp[i]); collection.storeResource(document); --- 1611,1621 ---- upload.setCurrentSize(temp[i].length()); ! mimeType = MimeTable.getInstance().getContentTypeFor(temp[i].getName()); ! if(mimeType == null) upload.showMessage("File " + temp[i].getName() + " has an unknown " + "suffix. Cannot determine file type."); else { document = collection.createResource(temp[i] ! .getName(), mimeType.getXMLDBType()); document.setContent(temp[i]); collection.storeResource(document); *************** *** 1632,1651 **** return totalSize; } - - private String getResourceType(String name) { - int p = name.lastIndexOf('.'); - if(p < 0 || p + 1 == name.length()) - return null; - String suffix = name.substring(p + 1); - String resourceType = null; - if(suffix != null) { - if(Arrays.binarySearch(xmlSuffixes, suffix) < 0) { - if(Arrays.binarySearch(binarySuffixes, suffix) > -1) - resourceType = "BinaryResource"; - } else - resourceType = "XMLResource"; - } - return resourceType; - } private void mkcol(String collPath) throws XMLDBException { --- 1632,1635 ---- *************** *** 1778,1782 **** boolean foundCollection = false; boolean openQueryGui = false; ! boolean doParse = false; boolean doReindex = false; String optionRemove = null; --- 1762,1766 ---- boolean foundCollection = false; boolean openQueryGui = false; ! boolean doStore = false; boolean doReindex = false; String optionRemove = null; *************** *** 1833,1837 **** break; case PARSE_OPT : ! doParse = true; if (option.getArgumentCount() == 1) optionalArgs.add(option.getArgument()); --- 1817,1821 ---- break; case PARSE_OPT : ! doStore = true; if (option.getArgumentCount() == 1) optionalArgs.add(option.getArgument()); *************** *** 2079,2083 **** } } ! } else if (doParse) { if (!foundCollection) { System.err --- 2063,2067 ---- } } ! } else if (doStore) { if (!foundCollection) { System.err Index: ResourcePropertyDialog.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/ResourcePropertyDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ResourcePropertyDialog.java 6 Aug 2003 09:36:20 -0000 1.2 --- ResourcePropertyDialog.java 30 Jan 2005 14:17:09 -0000 1.3 *************** *** 44,47 **** --- 44,48 ---- Date creationDate; Date modificationDate; + String mimeType; JComboBox groups; JComboBox owners; *************** *** 63,74 **** Permission perm, Date created, ! Date modified) throws HeadlessException, XMLDBException { super(owner, "Edit Properties", true); ! service = mgt; ! permissions = perm; ! creationDate = created; ! modificationDate = modified; ! resource = res; setupComponents(); addWindowListener(new WindowAdapter() { --- 64,77 ---- Permission perm, Date created, ! Date modified, ! String mimeType) throws HeadlessException, XMLDBException { super(owner, "Edit Properties", true); ! this.service = mgt; ! this.permissions = perm; ! this.creationDate = created; ! this.modificationDate = modified; ! this.resource = res; ! this.mimeType = mimeType == null ? "N/A" : mimeType; setupComponents(); addWindowListener(new WindowAdapter() { *************** *** 110,116 **** getContentPane().add(label); label = new JLabel("Created:"); c.gridx = 0; ! c.gridy = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; --- 113,135 ---- getContentPane().add(label); + label = new JLabel("Mime:"); + c.gridx = 0; + c.gridy = 1; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.HORIZONTAL; + grid.setConstraints(label, c); + getContentPane().add(label); + + label = new JLabel(mimeType); + c.gridx = 1; + c.gridy = 1; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.HORIZONTAL; + grid.setConstraints(label, c); + getContentPane().add(label); + label = new JLabel("Created:"); c.gridx = 0; ! c.gridy = 2; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; *************** *** 121,125 **** label = new JLabel(date); c.gridx = 1; ! c.gridy = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; --- 140,144 ---- label = new JLabel(date); c.gridx = 1; ! c.gridy = 2; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; *************** *** 129,133 **** label = new JLabel("Last modified:"); c.gridx = 0; ! c.gridy = 2; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; --- 148,152 ---- label = new JLabel("Last modified:"); c.gridx = 0; ! c.gridy = 3; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; *************** *** 139,143 **** label = new JLabel(date); c.gridx = 1; ! c.gridy = 2; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; --- 158,162 ---- label = new JLabel(date); c.gridx = 1; ! c.gridy = 3; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; *************** *** 147,151 **** label = new JLabel("Owner"); c.gridx = 0; ! c.gridy = 3; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; --- 166,170 ---- label = new JLabel("Owner"); c.gridx = 0; ! c.gridy = 4; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; *************** *** 161,165 **** owners.setSelectedItem(permissions.getOwner()); c.gridx = 1; ! c.gridy = 3; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; --- 180,184 ---- owners.setSelectedItem(permissions.getOwner()); c.gridx = 1; ! c.gridy = 4; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; *************** *** 169,173 **** label = new JLabel("Group"); c.gridx = 0; ! c.gridy = 4; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; --- 188,192 ---- label = new JLabel("Group"); c.gridx = 0; ! c.gridy = 5; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; *************** *** 182,186 **** groups.setSelectedItem(permissions.getOwnerGroup()); c.gridx = 1; ! c.gridy = 4; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; --- 201,205 ---- groups.setSelectedItem(permissions.getOwnerGroup()); c.gridx = 1; ! c.gridy = 5; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; *************** *** 190,194 **** JComponent pc = setupPermissions(); c.gridx = 0; ! c.gridy = 5; c.gridwidth = 2; c.anchor = GridBagConstraints.EAST; --- 209,213 ---- JComponent pc = setupPermissions(); c.gridx = 0; ! c.gridy = 6; c.gridwidth = 2; c.anchor = GridBagConstraints.EAST; *************** *** 215,219 **** c.gridx = 1; ! c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; --- 234,238 ---- c.gridx = 1; ! c.gridy = 7; c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 10:54:50
|
Update of /cvsroot/exist/eXist-1.0/lib/optional In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9562/lib/optional Modified Files: jgroups-all.jar Log Message: Switched jgroups-all.jar to BINARY mode. |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 10:13:47
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2592/src/org/exist/util Modified Files: Configuration.java Log Message: Made XQuery pool settings configurable. Index: Configuration.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Configuration.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Configuration.java 8 Dec 2004 09:27:28 -0000 1.28 --- Configuration.java 30 Jan 2005 10:13:37 -0000 1.29 *************** *** 46,472 **** public class Configuration implements ErrorHandler { - - private final static Logger LOG = - Logger.getLogger( Configuration.class ); - - protected DocumentBuilder builder = null; - protected HashMap config = new HashMap(); - protected String file = null; ! public Configuration(String file) throws DatabaseConfigurationException { ! this(file, null); ! } ! public Configuration(String file, String dbHome) ! throws DatabaseConfigurationException { ! try { ! String pathSep = System.getProperty("file.separator", "/"); ! ! // first try to read the configuration from a file within the classpath ! InputStream is = Configuration.class.getClassLoader().getResourceAsStream(file); ! if(is != null) { ! LOG.info("Reading configuration from classloader"); ! this.file = file; ! } else { ! // try to read configuration from file. Guess the location if necessary ! File f = new File(file); ! if((!f.isAbsolute()) && dbHome != null) { ! file = dbHome + pathSep + file; ! f = new File(file); ! } ! if (!f.canRead()) { ! LOG.info("unable to read configuration. Trying to guess location ..."); ! ! // fall back and try to read from home directory ! if (dbHome == null) { ! // try to determine exist home directory ! dbHome = System.getProperty("exist.home"); ! ! if (dbHome == null) ! dbHome = System.getProperty("user.dir"); ! } ! ! if (dbHome != null) ! file = dbHome + pathSep + file; ! f = new File(file); ! if(!f.canRead()) { ! LOG.warn("giving up"); ! throw new DatabaseConfigurationException("unable to read configuration file"); ! } ! } ! this.file = file; ! is = new FileInputStream(file); ! } ! ! // initialize xml parser ! // we use eXist's in-memory DOM implementation to work ! // around a bug in Xerces ! SAXParserFactory factory = SAXParserFactory.newInstance(); ! factory.setNamespaceAware(true); ! InputSource src = new InputSource(is); ! SAXParser parser = factory.newSAXParser(); ! XMLReader reader = parser.getXMLReader(); ! SAXAdapter adapter = new SAXAdapter(); ! reader.setContentHandler(adapter); ! reader.parse(src); ! Document doc = adapter.getDocument(); ! ! // DocumentBuilderFactory factory = ! // DocumentBuilderFactory.newInstance(); ! // factory.setNamespaceAware(true); ! // ! // builder = factory.newDocumentBuilder(); ! // builder.setErrorHandler(this); ! // InputSource src = new InputSource(is); ! // Document doc = builder.parse(src); ! Element root = doc.getDocumentElement(); ! ! // indexer settings ! NodeList indexer = doc.getElementsByTagName("indexer"); ! if (indexer.getLength() > 0) { ! Element p = (Element) indexer.item(0); ! String parseNum = p.getAttribute("parseNumbers"); ! String indexDepth = p.getAttribute("index-depth"); ! String stemming = p.getAttribute("stemming"); ! String termFreq = p.getAttribute("track-term-freq"); ! String suppressWS = p.getAttribute("suppress-whitespace"); ! String caseSensitive = p.getAttribute("caseSensitive"); ! String tokenizer = p.getAttribute("tokenizer"); ! String validation = p.getAttribute("validation"); ! String suppressWSmixed = p.getAttribute("preserve-whitespace-mixed-content"); ! ! if (parseNum != null) ! config.put( ! "indexer.indexNumbers", ! Boolean.valueOf(parseNum.equals("yes"))); ! if (stemming != null) ! config.put("indexer.stem", Boolean.valueOf(stemming.equals("yes"))); ! if (termFreq != null) ! config.put("indexer.store-term-freq", Boolean.valueOf(termFreq.equals("yes"))); ! ! if (caseSensitive != null) ! config.put( ! "indexer.case-sensitive", ! Boolean.valueOf(caseSensitive.equals("yes"))); ! if (suppressWS != null) ! config.put("indexer.suppress-whitespace", suppressWS); ! if (validation != null) ! config.put("indexer.validation", validation); ! if (tokenizer != null) ! config.put("indexer.tokenizer", tokenizer); ! ! if (indexDepth != null) ! try { ! int depth = Integer.parseInt(indexDepth); ! config.put("indexer.index-depth", new Integer(depth)); ! } catch (NumberFormatException e) { ! } ! if (suppressWSmixed != null) ! config.put( ! "indexer.preserve-whitespace-mixed-content", ! Boolean.valueOf(suppressWSmixed.equals("yes"))); ! ! // index settings ! NodeList cl = doc.getElementsByTagName("index"); ! if(cl.getLength() > 0) { ! Element elem = (Element) cl.item(0); ! IndexSpec spec = new IndexSpec(elem); ! config.put("indexer.config", spec); ! } ! // stopwords ! NodeList stopwords = p.getElementsByTagName("stopwords"); ! if (stopwords.getLength() > 0) { ! String stopwordFile = ! ((Element) stopwords.item(0)).getAttribute("file"); ! File sf = new File(stopwordFile); ! if (!sf.canRead()) { ! stopwordFile = dbHome + pathSep + stopwordFile; ! sf = new File(stopwordFile); ! } ! if (sf.canRead()) ! config.put("stopwords", stopwordFile); ! } ! CatalogResolver resolver = new CatalogResolver(true); ! System.setProperty("xml.catalog.verbosity", "10"); ! config.put("resolver", resolver); ! NodeList entityResolver = ! p.getElementsByTagName("entity-resolver"); ! if (entityResolver.getLength() > 0) { ! Element r = (Element) entityResolver.item(0); ! NodeList catalogs = r.getElementsByTagName("catalog"); ! String catalog; ! File catalogFile; ! for (int i = 0; i < catalogs.getLength(); i++) { ! catalog = ! ((Element) catalogs.item(i)).getAttribute("file"); ! if (pathSep.equals("\\")) ! catalog = catalog.replace('/', '\\'); ! if (dbHome == null) ! catalogFile = new File(catalog); ! else ! catalogFile = new File(dbHome + pathSep + catalog); ! if (catalogFile.exists()) { ! resolver.getCatalog().parseCatalog( ! catalogFile.getAbsolutePath()); ! } ! } ! } ! } ! NodeList dbcon = doc.getElementsByTagName("db-connection"); ! if (dbcon.getLength() > 0) { ! Element con = (Element) dbcon.item(0); ! String cacheMem = con.getAttribute("cacheSize"); ! String pageSize = con.getAttribute("pageSize"); ! String dataFiles = con.getAttribute("files"); ! String buffers = con.getAttribute("buffers"); ! String collBuffers = con.getAttribute("collection_buffers"); ! String wordBuffers = con.getAttribute("words_buffers"); ! String elementBuffers = con.getAttribute("elements_buffers"); ! String freeMem = con.getAttribute("free_mem_min"); ! String mysql = con.getAttribute("database"); ! if (mysql != null) ! config.put("database", mysql); ! // directory for database files ! if (dataFiles != null) { ! File df = new File(dataFiles); ! if ((!df.isAbsolute()) && dbHome != null) { ! dataFiles = dbHome + pathSep + dataFiles; ! df = new File(dataFiles); ! } ! if (!df.canRead()) ! throw new DatabaseConfigurationException( ! "cannot read data directory: " ! + df.getAbsolutePath()); ! config.put("db-connection.data-dir", df.getAbsolutePath()); ! LOG.info("data directory = " + df.getAbsolutePath()); ! } ! if (cacheMem != null) { ! if(cacheMem.endsWith("M") || cacheMem.endsWith("m")) ! cacheMem = cacheMem.substring(0, cacheMem.length() - 1); ! try { ! config.put( ! "db-connection.cache-size", ! new Integer(cacheMem)); ! } catch (NumberFormatException nfe) { ! } ! } ! if (buffers != null) ! try { ! config.put( ! "db-connection.buffers", ! new Integer(buffers)); ! } catch (NumberFormatException nfe) { ! } ! if (pageSize != null) ! try { ! config.put( ! "db-connection.page-size", ! new Integer(pageSize)); ! } catch (NumberFormatException nfe) { ! } ! if (collBuffers != null) ! try { ! config.put( ! "db-connection.collections.buffers", ! new Integer(collBuffers)); ! } catch (NumberFormatException nfe) { ! } ! if (wordBuffers != null) ! try { ! config.put( ! "db-connection.words.buffers", ! new Integer(wordBuffers)); ! } catch (NumberFormatException nfe) { ! } ! if (elementBuffers != null) ! try { ! config.put( ! "db-connection.elements.buffers", ! new Integer(elementBuffers)); ! } catch (NumberFormatException nfe) { ! } ! if (freeMem != null) ! try { ! config.put( ! "db-connection.min_free_memory", ! new Integer(freeMem)); ! } catch (NumberFormatException nfe) { ! } ! NodeList poolConf = con.getElementsByTagName("pool"); ! if(poolConf.getLength() > 0) { ! Element pool = (Element)poolConf.item(0); ! String min = pool.getAttribute("min"); ! String max = pool.getAttribute("max"); ! String sync = pool.getAttribute("sync-period"); ! String maxShutdownWait = pool.getAttribute("wait-before-shutdown"); ! if(min != null) ! try { ! config.put("db-connection.pool.min", ! new Integer(min)); ! } catch(NumberFormatException e) { ! } ! if(max != null) ! try { ! config.put("db-connection.pool.max", ! new Integer(max)); ! } catch(NumberFormatException e) { ! } ! if(sync!= null) ! try { ! config.put("db-connection.pool.sync-period", ! new Long(sync)); ! } catch(NumberFormatException e) { ! } ! if(maxShutdownWait != null) ! try { ! config.put("db-connection.pool.shutdown-wait", ! new Long(maxShutdownWait)); ! } catch(NumberFormatException e) { ! } ! } ! NodeList watchConf = con.getElementsByTagName("watchdog"); ! if(watchConf.getLength() > 0) { ! Element watchDog = (Element)watchConf.item(0); ! String timeout = watchDog.getAttribute("query-timeout"); ! String maxOutput = watchDog.getAttribute("output-size-limit"); ! if(timeout != null) { ! try { ! config.put("db-connection.watchdog.query-timeout", new Long(timeout)); ! } catch(NumberFormatException e) { ! } ! } ! if(maxOutput != null) { ! try { ! config.put("db-connection.watchdog.output-size-limit", new Integer(maxOutput)); ! } catch(NumberFormatException e) { ! } ! } ! } ! } ! NodeList serializers = doc.getElementsByTagName("serializer"); ! Element serializer; ! if(serializers.getLength() > 0) { ! serializer = (Element)serializers.item(0); ! String xinclude = serializer.getAttribute("enable-xinclude"); ! if(xinclude != null) ! config.put("serialization.enable-xinclude", xinclude); ! String xsl = serializer.getAttribute("enable-xsl"); ! if(xsl != null) ! config.put("serialization.enable-xsl", xsl); ! String indent = serializer.getAttribute("indent"); ! if(indent != null) ! config.put("serialization.indent", indent); String internalId = serializer.getAttribute("add-exist-id"); ! if(internalId != null) config.put("serialization.add-exist-id", internalId); ! String tagElementMatches = serializer.getAttribute("match-tagging-elements"); ! if(tagElementMatches != null) ! config.put("serialization.match-tagging-elements", tagElementMatches); ! String tagAttributeMatches = serializer.getAttribute("match-tagging-attributes"); ! if(tagAttributeMatches != null) ! config.put("serialization.match-tagging-attributes", tagAttributeMatches); ! } ! ! NodeList xupdates = doc.getElementsByTagName("xupdate"); ! Element xupdate; ! if(xupdates.getLength() > 0) { ! xupdate = (Element)xupdates.item(0); ! String growth = xupdate.getAttribute("growth-factor"); ! if(growth != null) { ! config.put("xupdate.growth-factor", new Integer(growth)); ! } ! String fragmentation = xupdate.getAttribute("allowed-fragmentation"); ! if(fragmentation != null) ! config.put("xupdate.fragmentation", new Integer(fragmentation)); ! ! String consistencyCheck = xupdate.getAttribute("enable-consistency-checks"); ! if(consistencyCheck != null) ! config.put("xupdate.consistency-checks", Boolean.valueOf(consistencyCheck.equals("yes"))); ! } ! } catch (SAXException e) { ! LOG.warn("error while reading config file: " + file, e); ! throw new DatabaseConfigurationException(e.getMessage()); ! } catch (ParserConfigurationException cfg) { ! LOG.warn("error while reading config file: " + file, cfg); ! throw new DatabaseConfigurationException(cfg.getMessage()); ! } catch (IOException io) { ! LOG.warn("error while reading config file: " + file, io); ! throw new DatabaseConfigurationException(io.getMessage()); ! } ! } ! public int getInteger(String name) { ! Object obj = getProperty(name); ! if ((obj == null) || !(obj instanceof Integer)) ! return -1; ! return ((Integer) obj).intValue(); ! } ! public String getPath() { ! return file; ! } ! public Object getProperty(String name) { ! return config.get(name); ! } ! public boolean hasProperty(String name) { ! return config.containsKey(name); ! } ! public void setProperty(String name, Object obj) { ! config.put(name, obj); ! } ! public void error(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " + "[line: " + exception.getLineNumber() + "]:" + ! exception.getMessage()); ! } ! /* (non-Javadoc) ! * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) ! */ ! public void fatalError(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " + ! "[line: " + exception.getLineNumber() + "]:" + ! exception.getMessage()); ! } ! /* (non-Javadoc) ! * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) ! */ ! public void warning(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " + ! "[line: " + exception.getLineNumber() + "]:" + ! exception.getMessage()); ! } } --- 46,519 ---- public class Configuration implements ErrorHandler { ! private final static Logger LOG = Logger.getLogger(Configuration.class); ! protected DocumentBuilder builder = null; ! protected HashMap config = new HashMap(); ! protected String file = null; ! public Configuration(String file) throws DatabaseConfigurationException { ! this(file, null); ! } ! public Configuration(String file, String dbHome) ! throws DatabaseConfigurationException { ! try { ! String pathSep = System.getProperty("file.separator", "/"); ! // first try to read the configuration from a file within the ! // classpath ! InputStream is = Configuration.class.getClassLoader() ! .getResourceAsStream(file); ! if (is != null) { ! LOG.info("Reading configuration from classloader"); ! this.file = file; ! } else { ! // try to read configuration from file. Guess the location if ! // necessary ! File f = new File(file); ! if ((!f.isAbsolute()) && dbHome != null) { ! file = dbHome + pathSep + file; ! f = new File(file); ! } ! if (!f.canRead()) { ! LOG ! .info("unable to read configuration. Trying to guess location ..."); ! // fall back and try to read from home directory ! if (dbHome == null) { ! // try to determine exist home directory ! dbHome = System.getProperty("exist.home"); ! if (dbHome == null) ! dbHome = System.getProperty("user.dir"); ! } ! if (dbHome != null) ! file = dbHome + pathSep + file; ! f = new File(file); ! if (!f.canRead()) { ! LOG.warn("giving up"); ! throw new DatabaseConfigurationException( ! "unable to read configuration file"); ! } ! } ! this.file = file; ! is = new FileInputStream(file); ! } ! // initialize xml parser ! // we use eXist's in-memory DOM implementation to work ! // around a bug in Xerces ! SAXParserFactory factory = SAXParserFactory.newInstance(); ! factory.setNamespaceAware(true); ! InputSource src = new InputSource(is); ! SAXParser parser = factory.newSAXParser(); ! XMLReader reader = parser.getXMLReader(); ! SAXAdapter adapter = new SAXAdapter(); ! reader.setContentHandler(adapter); ! reader.parse(src); ! Document doc = adapter.getDocument(); ! // DocumentBuilderFactory factory = ! // DocumentBuilderFactory.newInstance(); ! // factory.setNamespaceAware(true); ! // ! // builder = factory.newDocumentBuilder(); ! // builder.setErrorHandler(this); ! // InputSource src = new InputSource(is); ! // Document doc = builder.parse(src); ! Element root = doc.getDocumentElement(); ! // indexer settings ! NodeList indexer = doc.getElementsByTagName("indexer"); ! if (indexer.getLength() > 0) { ! Element p = (Element) indexer.item(0); ! String parseNum = p.getAttribute("parseNumbers"); ! String indexDepth = p.getAttribute("index-depth"); ! String stemming = p.getAttribute("stemming"); ! String termFreq = p.getAttribute("track-term-freq"); ! String suppressWS = p.getAttribute("suppress-whitespace"); ! String caseSensitive = p.getAttribute("caseSensitive"); ! String tokenizer = p.getAttribute("tokenizer"); ! String validation = p.getAttribute("validation"); ! String suppressWSmixed = p ! .getAttribute("preserve-whitespace-mixed-content"); ! if (parseNum != null) ! config.put("indexer.indexNumbers", Boolean.valueOf(parseNum ! .equals("yes"))); ! if (stemming != null) ! config.put("indexer.stem", Boolean.valueOf(stemming ! .equals("yes"))); ! if (termFreq != null) ! config.put("indexer.store-term-freq", Boolean ! .valueOf(termFreq.equals("yes"))); ! if (caseSensitive != null) ! config.put("indexer.case-sensitive", Boolean ! .valueOf(caseSensitive.equals("yes"))); ! if (suppressWS != null) ! config.put("indexer.suppress-whitespace", suppressWS); ! if (validation != null) ! config.put("indexer.validation", validation); ! if (tokenizer != null) ! config.put("indexer.tokenizer", tokenizer); ! if (indexDepth != null) ! try { ! int depth = Integer.parseInt(indexDepth); ! config.put("indexer.index-depth", new Integer(depth)); ! } catch (NumberFormatException e) { ! } ! if (suppressWSmixed != null) ! config.put("indexer.preserve-whitespace-mixed-content", ! Boolean.valueOf(suppressWSmixed.equals("yes"))); ! // index settings ! NodeList cl = doc.getElementsByTagName("index"); ! if (cl.getLength() > 0) { ! Element elem = (Element) cl.item(0); ! IndexSpec spec = new IndexSpec(elem); ! config.put("indexer.config", spec); ! } ! // stopwords ! NodeList stopwords = p.getElementsByTagName("stopwords"); ! if (stopwords.getLength() > 0) { ! String stopwordFile = ((Element) stopwords.item(0)) ! .getAttribute("file"); ! File sf = new File(stopwordFile); ! if (!sf.canRead()) { ! stopwordFile = dbHome + pathSep + stopwordFile; ! sf = new File(stopwordFile); ! } ! if (sf.canRead()) ! config.put("stopwords", stopwordFile); ! } ! CatalogResolver resolver = new CatalogResolver(true); ! System.setProperty("xml.catalog.verbosity", "10"); ! config.put("resolver", resolver); ! NodeList entityResolver = p ! .getElementsByTagName("entity-resolver"); ! if (entityResolver.getLength() > 0) { ! Element r = (Element) entityResolver.item(0); ! NodeList catalogs = r.getElementsByTagName("catalog"); ! String catalog; ! File catalogFile; ! for (int i = 0; i < catalogs.getLength(); i++) { ! catalog = ((Element) catalogs.item(i)) ! .getAttribute("file"); ! ! if (pathSep.equals("\\")) ! catalog = catalog.replace('/', '\\'); ! ! if (dbHome == null) ! catalogFile = new File(catalog); ! else ! catalogFile = new File(dbHome + pathSep + catalog); ! if (catalogFile.exists()) { ! resolver.getCatalog().parseCatalog( ! catalogFile.getAbsolutePath()); ! } ! } ! } ! } ! ! NodeList dbcon = doc.getElementsByTagName("db-connection"); ! ! if (dbcon.getLength() > 0) { ! Element con = (Element) dbcon.item(0); ! String cacheMem = con.getAttribute("cacheSize"); ! String pageSize = con.getAttribute("pageSize"); ! String dataFiles = con.getAttribute("files"); ! String buffers = con.getAttribute("buffers"); ! String collBuffers = con.getAttribute("collection_buffers"); ! String wordBuffers = con.getAttribute("words_buffers"); ! String elementBuffers = con.getAttribute("elements_buffers"); ! String freeMem = con.getAttribute("free_mem_min"); ! String mysql = con.getAttribute("database"); ! ! if (mysql != null) ! config.put("database", mysql); ! ! // directory for database files ! if (dataFiles != null) { ! File df = new File(dataFiles); ! if ((!df.isAbsolute()) && dbHome != null) { ! dataFiles = dbHome + pathSep + dataFiles; ! df = new File(dataFiles); ! } ! if (!df.canRead()) ! throw new DatabaseConfigurationException( ! "cannot read data directory: " ! + df.getAbsolutePath()); ! ! config.put("db-connection.data-dir", df.getAbsolutePath()); ! LOG.info("data directory = " + df.getAbsolutePath()); ! } ! ! if (cacheMem != null) { ! if (cacheMem.endsWith("M") || cacheMem.endsWith("m")) ! cacheMem = cacheMem.substring(0, cacheMem.length() - 1); ! try { ! config.put("db-connection.cache-size", new Integer( ! cacheMem)); ! } catch (NumberFormatException nfe) { ! } ! } ! ! if (buffers != null) ! try { ! config.put("db-connection.buffers", ! new Integer(buffers)); ! } catch (NumberFormatException nfe) { ! } ! ! if (pageSize != null) ! try { ! config.put("db-connection.page-size", new Integer( ! pageSize)); ! } catch (NumberFormatException nfe) { ! } ! ! if (collBuffers != null) ! try { ! config.put("db-connection.collections.buffers", ! new Integer(collBuffers)); ! } catch (NumberFormatException nfe) { ! } ! ! if (wordBuffers != null) ! try { ! config.put("db-connection.words.buffers", new Integer( ! wordBuffers)); ! } catch (NumberFormatException nfe) { ! } ! ! if (elementBuffers != null) ! try { ! config.put("db-connection.elements.buffers", ! new Integer(elementBuffers)); ! } catch (NumberFormatException nfe) { ! } ! ! if (freeMem != null) ! try { ! config.put("db-connection.min_free_memory", ! new Integer(freeMem)); ! } catch (NumberFormatException nfe) { ! } ! NodeList poolConf = con.getElementsByTagName("pool"); ! if (poolConf.getLength() > 0) { ! Element pool = (Element) poolConf.item(0); ! String min = pool.getAttribute("min"); ! String max = pool.getAttribute("max"); ! String sync = pool.getAttribute("sync-period"); ! String maxShutdownWait = pool ! .getAttribute("wait-before-shutdown"); ! if (min != null) ! try { ! config.put("db-connection.pool.min", new Integer( ! min)); ! } catch (NumberFormatException e) { ! } ! if (max != null) ! try { ! config.put("db-connection.pool.max", new Integer( ! max)); ! } catch (NumberFormatException e) { ! } ! if (sync != null) ! try { ! config.put("db-connection.pool.sync-period", ! new Long(sync)); ! } catch (NumberFormatException e) { ! } ! if (maxShutdownWait != null) ! try { ! config.put("db-connection.pool.shutdown-wait", ! new Long(maxShutdownWait)); ! } catch (NumberFormatException e) { ! } ! } ! NodeList queryPoolConf = con.getElementsByTagName("query-pool"); ! if (queryPoolConf.getLength() > 0) { ! Element queryPool = (Element) queryPoolConf.item(0); ! String maxStackSize = queryPool ! .getAttribute("max-stack-size"); ! String timeout = queryPool.getAttribute("timeout"); ! String timeoutCheckInterval = queryPool ! .getAttribute("timeout-check-interval"); ! if (maxStackSize != null) ! try { ! config.put( ! "db-connection.query-pool.max-stack-size", ! new Integer(maxStackSize)); ! } catch (NumberFormatException e) { ! } ! if (timeout != null) ! try { ! config.put("db-connection.query-pool.timeout", ! new Long(timeout)); ! } catch (NumberFormatException e) { ! } ! if (timeoutCheckInterval != null) ! try { ! config ! .put( ! "db-connection.query-pool.timeout-check-interval", ! new Long(timeoutCheckInterval)); ! } catch (NumberFormatException e) { ! } ! } ! NodeList watchConf = con.getElementsByTagName("watchdog"); ! if (watchConf.getLength() > 0) { ! Element watchDog = (Element) watchConf.item(0); ! String timeout = watchDog.getAttribute("query-timeout"); ! String maxOutput = watchDog ! .getAttribute("output-size-limit"); ! if (timeout != null) { ! try { ! config.put("db-connection.watchdog.query-timeout", ! new Long(timeout)); ! } catch (NumberFormatException e) { ! } ! } ! if (maxOutput != null) { ! try { ! config.put( ! "db-connection.watchdog.output-size-limit", ! new Integer(maxOutput)); ! } catch (NumberFormatException e) { ! } ! } ! } ! } ! ! NodeList serializers = doc.getElementsByTagName("serializer"); ! Element serializer; ! if (serializers.getLength() > 0) { ! serializer = (Element) serializers.item(0); ! String xinclude = serializer.getAttribute("enable-xinclude"); ! if (xinclude != null) ! config.put("serialization.enable-xinclude", xinclude); ! String xsl = serializer.getAttribute("enable-xsl"); ! if (xsl != null) ! config.put("serialization.enable-xsl", xsl); ! String indent = serializer.getAttribute("indent"); ! if (indent != null) ! config.put("serialization.indent", indent); String internalId = serializer.getAttribute("add-exist-id"); ! if (internalId != null) config.put("serialization.add-exist-id", internalId); ! String tagElementMatches = serializer ! .getAttribute("match-tagging-elements"); ! if (tagElementMatches != null) ! config.put("serialization.match-tagging-elements", ! tagElementMatches); ! String tagAttributeMatches = serializer ! .getAttribute("match-tagging-attributes"); ! if (tagAttributeMatches != null) ! config.put("serialization.match-tagging-attributes", ! tagAttributeMatches); ! } ! NodeList xupdates = doc.getElementsByTagName("xupdate"); ! Element xupdate; ! if (xupdates.getLength() > 0) { ! xupdate = (Element) xupdates.item(0); ! String growth = xupdate.getAttribute("growth-factor"); ! if (growth != null) { ! config.put("xupdate.growth-factor", new Integer(growth)); ! } ! String fragmentation = xupdate ! .getAttribute("allowed-fragmentation"); ! if (fragmentation != null) ! config.put("xupdate.fragmentation", new Integer( ! fragmentation)); ! String consistencyCheck = xupdate ! .getAttribute("enable-consistency-checks"); ! if (consistencyCheck != null) ! config.put("xupdate.consistency-checks", Boolean ! .valueOf(consistencyCheck.equals("yes"))); ! } ! } catch (SAXException e) { ! LOG.warn("error while reading config file: " + file, e); ! throw new DatabaseConfigurationException(e.getMessage()); ! } catch (ParserConfigurationException cfg) { ! LOG.warn("error while reading config file: " + file, cfg); ! throw new DatabaseConfigurationException(cfg.getMessage()); ! } catch (IOException io) { ! LOG.warn("error while reading config file: " + file, io); ! throw new DatabaseConfigurationException(io.getMessage()); ! } ! } ! public int getInteger(String name) { ! Object obj = getProperty(name); ! if ((obj == null) || !(obj instanceof Integer)) ! return -1; ! return ((Integer) obj).intValue(); ! } ! public String getPath() { ! return file; ! } ! public Object getProperty(String name) { ! return config.get(name); ! } ! public boolean hasProperty(String name) { ! return config.containsKey(name); ! } ! public void setProperty(String name, Object obj) { ! config.put(name, obj); ! } ! public void error(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " ! + "[line: " + exception.getLineNumber() + "]:" ! + exception.getMessage()); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) ! */ ! public void fatalError(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " ! + "[line: " + exception.getLineNumber() + "]:" ! + exception.getMessage()); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) ! */ ! public void warning(SAXParseException exception) throws SAXException { ! System.err.println("error occured while reading configuration file " ! + "[line: " + exception.getLineNumber() + "]:" ! + exception.getMessage()); ! } } |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 10:13:47
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2592/src/org/exist/storage Modified Files: BrokerPool.java XQueryPool.java Log Message: Made XQuery pool settings configurable. Index: XQueryPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/XQueryPool.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XQueryPool.java 18 Nov 2004 21:24:21 -0000 1.3 --- XQueryPool.java 30 Jan 2005 10:13:36 -0000 1.4 *************** *** 28,81 **** import org.apache.log4j.Logger; import org.exist.source.Source; import org.exist.util.hashtable.Object2ObjectHashMap; import org.exist.xquery.CompiledXQuery; - /** * @author wolf */ public class XQueryPool extends Object2ObjectHashMap { ! private final static int MAX_STACK_SIZE = 5; ! ! private final static long TIMEOUT = 120000; ! private final static long TIMEOUT_CHECK_INTERVAL = 30000; ! private final static Logger LOG = Logger.getLogger(XQueryPool.class); ! private long lastTimeOutCheck; ! /** ! * */ ! protected XQueryPool() { super(27); lastTimeOutCheck = System.currentTimeMillis(); } ! public synchronized void returnCompiledXQuery(Source source, CompiledXQuery xquery) { ! if(xquery == null) ! return; ! Stack stack = (Stack)get(source); ! if(stack == null) { stack = new Stack(); source.setCacheTimestamp(System.currentTimeMillis()); put(source, stack); } ! if(stack.size() < MAX_STACK_SIZE) { stack.push(xquery); } timeoutCheck(); ! } ! public synchronized CompiledXQuery borrowCompiledXQuery(Source source) { int idx = getIndex(source); ! if(idx < 0) return null; ! Source key = (Source)keys[idx]; int validity = key.isValid(); ! if(validity == Source.UNKNOWN) validity = key.isValid(source); ! if(validity == Source.INVALID || validity == Source.UNKNOWN) { keys[idx] = REMOVED; values[idx] = null; --- 28,119 ---- import org.apache.log4j.Logger; import org.exist.source.Source; + import org.exist.util.Configuration; import org.exist.util.hashtable.Object2ObjectHashMap; import org.exist.xquery.CompiledXQuery; /** + * Global pool for pre-compiled XQuery expressions. Expressions are + * stored and retrieved from the pool by comparing the {@link org.exist.source.Source} + * objects from which they were created. For each XQuery, a maximum of + * {@link #MAX_STACK_SIZE} compiled expressions are kept in the pool. + * An XQuery expression will be removed from the pool if it has not been + * used for a pre-defined timeout. These settings can be configured in conf.xml. + * * @author wolf */ public class XQueryPool extends Object2ObjectHashMap { ! public final static int MAX_STACK_SIZE = 5; ! ! public final static long TIMEOUT = 120000; ! ! public final static long TIMEOUT_CHECK_INTERVAL = 30000; ! private final static Logger LOG = Logger.getLogger(XQueryPool.class); ! private long lastTimeOutCheck; ! ! private int maxStackSize; ! ! private long timeout; ! ! private long timeoutCheckInterval; ! /** ! * @param conf */ ! public XQueryPool(Configuration conf) { super(27); lastTimeOutCheck = System.currentTimeMillis(); + + Integer maxStSz = (Integer) conf + .getProperty("db-connection.query-pool.max-stack-size"); + Long t = (Long) conf.getProperty("db-connection.query-pool.timeout"); + Long tci = (Long) conf + .getProperty("db-connection.query-pool.timeout-check-interval"); + + if (maxStSz != null) + maxStackSize = maxStSz.intValue(); + else + maxStackSize = MAX_STACK_SIZE; + + if (t != null) + timeout = t.longValue(); + else + timeout = TIMEOUT; + + if (tci != null) + timeoutCheckInterval = tci.longValue(); + else + timeoutCheckInterval = TIMEOUT_CHECK_INTERVAL; + + LOG.info("QueryPool: maxStackSize = " + maxStackSize + "; timeout = " + + timeout + "; timeoutCheckInterval = " + timeoutCheckInterval); + } ! public synchronized void returnCompiledXQuery(Source source, ! CompiledXQuery xquery) { ! Stack stack = (Stack) get(source); ! if (stack == null) { stack = new Stack(); source.setCacheTimestamp(System.currentTimeMillis()); put(source, stack); } ! if (stack.size() < maxStackSize) { stack.push(xquery); } timeoutCheck(); ! } ! public synchronized CompiledXQuery borrowCompiledXQuery(Source source) { int idx = getIndex(source); ! if (idx < 0) return null; ! Source key = (Source) keys[idx]; int validity = key.isValid(); ! if (validity == Source.UNKNOWN) validity = key.isValid(source); ! if (validity == Source.INVALID || validity == Source.UNKNOWN) { keys[idx] = REMOVED; values[idx] = null; *************** *** 83,108 **** return null; } ! Stack stack = (Stack)values[idx]; ! if(stack != null && !stack.isEmpty()) { ! CompiledXQuery query = (CompiledXQuery)stack.pop(); ! if(!query.isValid()) { ! // the compiled query is no longer valid: one of the imported ! // modules may have changed ! remove(key); ! return null; } else ! return query; } return null; } ! private void timeoutCheck() { final long currentTime = System.currentTimeMillis(); ! if(currentTime - lastTimeOutCheck < TIMEOUT_CHECK_INTERVAL) return; ! ! for(Iterator i = iterator(); i.hasNext(); ) { ! Source next = (Source)i.next(); ! if(currentTime - next.getCacheTimestamp() > TIMEOUT) remove(next); } --- 121,146 ---- return null; } ! Stack stack = (Stack) values[idx]; ! if (stack != null && !stack.isEmpty()) { ! CompiledXQuery query = (CompiledXQuery) stack.pop(); ! if (!query.isValid()) { ! // the compiled query is no longer valid: one of the imported ! // modules may have changed ! remove(key); ! return null; } else ! return query; } return null; } ! private void timeoutCheck() { final long currentTime = System.currentTimeMillis(); ! if (currentTime - lastTimeOutCheck < timeoutCheckInterval) return; ! ! for (Iterator i = iterator(); i.hasNext();) { ! Source next = (Source) i.next(); ! if (currentTime - next.getCacheTimestamp() > timeout) remove(next); } Index: BrokerPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/BrokerPool.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** BrokerPool.java 10 Dec 2004 18:46:53 -0000 1.41 --- BrokerPool.java 30 Jan 2005 10:13:36 -0000 1.42 *************** *** 277,281 **** syncDaemon.executePeriodically(1000, new Sync(this, syncPeriod), false); conf = config; ! xqueryCache = new XQueryPool(); monitor = new XQueryMonitor(); collectionsCache = new CollectionCache(this, COLLECTION_BUFFER_SIZE); --- 277,281 ---- syncDaemon.executePeriodically(1000, new Sync(this, syncPeriod), false); conf = config; ! xqueryCache = new XQueryPool(conf); monitor = new XQueryMonitor(); collectionsCache = new CollectionCache(this, COLLECTION_BUFFER_SIZE); |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 10:13:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2592/src/org/exist/source Modified Files: CocoonSource.java Added Files: DBSource.java Log Message: Made XQuery pool settings configurable. --- NEW FILE: DBSource.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: DBSource.java,v 1.1 2005/01/30 10:13:35 wolfgang_m Exp $ */ package org.exist.source; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import org.exist.dom.BinaryDocument; import org.exist.storage.DBBroker; /** * Source implementation that reads from a binary resource * stored in the database. * * @author wolf */ public class DBSource extends AbstractSource { private BinaryDocument doc; private String key; private long lastModified; private String encoding = "UTF-8"; private boolean checkEncoding; private DBBroker broker; public DBSource(DBBroker broker, BinaryDocument doc, boolean checkXQEncoding) { this.broker = broker; this.doc = doc; this.key = doc.getName(); this.lastModified = doc.getLastModified(); this.checkEncoding = checkXQEncoding; } /* (non-Javadoc) * @see org.exist.source.Source#getKey() */ public Object getKey() { return key; } public long getLastModified() { return lastModified; } /* (non-Javadoc) * @see org.exist.source.Source#isValid() */ public int isValid() { return UNKNOWN; } /* (non-Javadoc) * @see org.exist.source.Source#isValid(org.exist.source.Source) */ public int isValid(Source other) { if(!(other instanceof DBSource)) return INVALID; DBSource source = (DBSource) other; if(source.getLastModified() > lastModified) return INVALID; return VALID; } /* (non-Javadoc) * @see org.exist.source.Source#getReader() */ public Reader getReader() throws IOException { byte[] data = broker.getBinaryResourceData(doc); ByteArrayInputStream is = new ByteArrayInputStream(data); checkEncoding(is); is.reset(); return new InputStreamReader(is, encoding); } /* (non-Javadoc) * @see org.exist.source.Source#getContent() */ public String getContent() throws IOException { byte[] data = broker.getBinaryResourceData(doc); ByteArrayInputStream is = new ByteArrayInputStream(data); checkEncoding(is); return new String(data, encoding); } private void checkEncoding(InputStream is) throws IOException { if (checkEncoding) { String checkedEnc = guessXQueryEncoding(is); if (checkedEnc != null) encoding = checkedEnc; } } } Index: CocoonSource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/source/CocoonSource.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CocoonSource.java 23 Jan 2005 20:29:45 -0000 1.4 --- CocoonSource.java 30 Jan 2005 10:13:35 -0000 1.5 *************** *** 24,28 **** import java.io.ByteArrayOutputStream; - import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; --- 24,27 ---- |
|
From: Wolfgang M. M. <wol...@us...> - 2005-01-30 10:13:44
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2592/src/org/exist/dom Modified Files: BinaryDocument.java Log Message: Made XQuery pool settings configurable. Index: BinaryDocument.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/BinaryDocument.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BinaryDocument.java 23 Jan 2005 20:29:46 -0000 1.6 --- BinaryDocument.java 30 Jan 2005 10:13:36 -0000 1.7 *************** *** 44,49 **** */ public class BinaryDocument extends DocumentImpl { - - public final static byte DATA = -1; private long pageNr = -1; --- 44,47 ---- |