Browse Source

Added fuseki data

IanKelly121 4 years ago
parent
commit
bf3304530c
100 changed files with 9750 additions and 0 deletions
  1. BIN
      OSiDatastore/GOSP.dat
  2. BIN
      OSiDatastore/GOSP.idn
  3. BIN
      OSiDatastore/GPOS.dat
  4. BIN
      OSiDatastore/GPOS.idn
  5. BIN
      OSiDatastore/GSPO.dat
  6. BIN
      OSiDatastore/GSPO.idn
  7. BIN
      OSiDatastore/OSP.dat
  8. BIN
      OSiDatastore/OSP.idn
  9. BIN
      OSiDatastore/OSPG.dat
  10. BIN
      OSiDatastore/OSPG.idn
  11. BIN
      OSiDatastore/POS.dat
  12. BIN
      OSiDatastore/POS.idn
  13. BIN
      OSiDatastore/POSG.dat
  14. BIN
      OSiDatastore/POSG.idn
  15. BIN
      OSiDatastore/SPO.dat
  16. BIN
      OSiDatastore/SPO.idn
  17. BIN
      OSiDatastore/SPOG.dat
  18. BIN
      OSiDatastore/SPOG.idn
  19. 0 0
      OSiDatastore/journal.jrnl
  20. BIN
      OSiDatastore/node2id.dat
  21. BIN
      OSiDatastore/node2id.idn
  22. BIN
      OSiDatastore/nodes.dat
  23. BIN
      OSiDatastore/prefix2id.dat
  24. BIN
      OSiDatastore/prefix2id.idn
  25. BIN
      OSiDatastore/prefixIdx.dat
  26. BIN
      OSiDatastore/prefixIdx.idn
  27. BIN
      OSiDatastore/prefixes.dat
  28. 617 0
      apache-jena-fuseki-3.12.0/LICENSE
  29. 216 0
      apache-jena-fuseki-3.12.0/NOTICE
  30. 62 0
      apache-jena-fuseki-3.12.0/README
  31. 725 0
      apache-jena-fuseki-3.12.0/bin/s-delete
  32. 725 0
      apache-jena-fuseki-3.12.0/bin/s-get
  33. 725 0
      apache-jena-fuseki-3.12.0/bin/s-head
  34. 725 0
      apache-jena-fuseki-3.12.0/bin/s-post
  35. 725 0
      apache-jena-fuseki-3.12.0/bin/s-put
  36. 725 0
      apache-jena-fuseki-3.12.0/bin/s-query
  37. 725 0
      apache-jena-fuseki-3.12.0/bin/s-update
  38. 725 0
      apache-jena-fuseki-3.12.0/bin/s-update-form
  39. 725 0
      apache-jena-fuseki-3.12.0/bin/soh
  40. 512 0
      apache-jena-fuseki-3.12.0/fuseki
  41. 34 0
      apache-jena-fuseki-3.12.0/fuseki-backup
  42. 95 0
      apache-jena-fuseki-3.12.0/fuseki-server
  43. 28 0
      apache-jena-fuseki-3.12.0/fuseki-server.bat
  44. BIN
      apache-jena-fuseki-3.12.0/fuseki-server.jar
  45. 59 0
      apache-jena-fuseki-3.12.0/fuseki.service
  46. BIN
      apache-jena-fuseki-3.12.0/fuseki.war
  47. 30 0
      apache-jena-fuseki-3.12.0/run/config.ttl
  48. 38 0
      apache-jena-fuseki-3.12.0/run/shiro.ini
  49. BIN
      apache-jena-fuseki-3.12.0/run/system/GOSP.dat
  50. BIN
      apache-jena-fuseki-3.12.0/run/system/GOSP.idn
  51. BIN
      apache-jena-fuseki-3.12.0/run/system/GPOS.dat
  52. BIN
      apache-jena-fuseki-3.12.0/run/system/GPOS.idn
  53. BIN
      apache-jena-fuseki-3.12.0/run/system/GSPO.dat
  54. BIN
      apache-jena-fuseki-3.12.0/run/system/GSPO.idn
  55. BIN
      apache-jena-fuseki-3.12.0/run/system/OSP.dat
  56. BIN
      apache-jena-fuseki-3.12.0/run/system/OSP.idn
  57. BIN
      apache-jena-fuseki-3.12.0/run/system/OSPG.dat
  58. BIN
      apache-jena-fuseki-3.12.0/run/system/OSPG.idn
  59. BIN
      apache-jena-fuseki-3.12.0/run/system/POS.dat
  60. BIN
      apache-jena-fuseki-3.12.0/run/system/POS.idn
  61. BIN
      apache-jena-fuseki-3.12.0/run/system/POSG.dat
  62. BIN
      apache-jena-fuseki-3.12.0/run/system/POSG.idn
  63. BIN
      apache-jena-fuseki-3.12.0/run/system/SPO.dat
  64. BIN
      apache-jena-fuseki-3.12.0/run/system/SPO.idn
  65. BIN
      apache-jena-fuseki-3.12.0/run/system/SPOG.dat
  66. BIN
      apache-jena-fuseki-3.12.0/run/system/SPOG.idn
  67. 0 0
      apache-jena-fuseki-3.12.0/run/system/journal.jrnl
  68. BIN
      apache-jena-fuseki-3.12.0/run/system/node2id.dat
  69. BIN
      apache-jena-fuseki-3.12.0/run/system/node2id.idn
  70. 0 0
      apache-jena-fuseki-3.12.0/run/system/nodes.dat
  71. BIN
      apache-jena-fuseki-3.12.0/run/system/prefix2id.dat
  72. BIN
      apache-jena-fuseki-3.12.0/run/system/prefix2id.idn
  73. BIN
      apache-jena-fuseki-3.12.0/run/system/prefixIdx.dat
  74. BIN
      apache-jena-fuseki-3.12.0/run/system/prefixIdx.idn
  75. 0 0
      apache-jena-fuseki-3.12.0/run/system/prefixes.dat
  76. 32 0
      apache-jena-fuseki-3.12.0/run/system/tdb.cfg
  77. 27 0
      apache-jena-fuseki-3.12.0/run/templates/config-mem
  78. 23 0
      apache-jena-fuseki-3.12.0/run/templates/config-service
  79. 31 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb
  80. 30 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb-dir
  81. 30 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb-mem
  82. 31 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb2
  83. 30 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb2-dir
  84. 30 0
      apache-jena-fuseki-3.12.0/run/templates/config-tdb2-mem
  85. 332 0
      apache-jena-fuseki-3.12.0/webapp/WEB-INF/web.xml
  86. 73 0
      apache-jena-fuseki-3.12.0/webapp/admin-logs.html
  87. 6 0
      apache-jena-fuseki-3.12.0/webapp/css/bootstrap-select.min.css
  88. 0 0
      apache-jena-fuseki-3.12.0/webapp/css/bootstrap-theme.css.map
  89. 6 0
      apache-jena-fuseki-3.12.0/webapp/css/bootstrap-theme.min.css
  90. 0 0
      apache-jena-fuseki-3.12.0/webapp/css/bootstrap.css.map
  91. 6 0
      apache-jena-fuseki-3.12.0/webapp/css/bootstrap.min.css
  92. 301 0
      apache-jena-fuseki-3.12.0/webapp/css/codemirror.css
  93. 0 0
      apache-jena-fuseki-3.12.0/webapp/css/codemirror.min.css
  94. 3 0
      apache-jena-fuseki-3.12.0/webapp/css/font-awesome.min.css
  95. 191 0
      apache-jena-fuseki-3.12.0/webapp/css/fui.css
  96. 220 0
      apache-jena-fuseki-3.12.0/webapp/css/jquery.dataTables.css
  97. 22 0
      apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-noscript.css
  98. 17 0
      apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-ui-noscript.css
  99. 57 0
      apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-ui.css
  100. 36 0
      apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload.css

BIN
OSiDatastore/GOSP.dat


BIN
OSiDatastore/GOSP.idn


BIN
OSiDatastore/GPOS.dat


BIN
OSiDatastore/GPOS.idn


BIN
OSiDatastore/GSPO.dat


BIN
OSiDatastore/GSPO.idn


BIN
OSiDatastore/OSP.dat


BIN
OSiDatastore/OSP.idn


BIN
OSiDatastore/OSPG.dat


BIN
OSiDatastore/OSPG.idn


BIN
OSiDatastore/POS.dat


BIN
OSiDatastore/POS.idn


BIN
OSiDatastore/POSG.dat


BIN
OSiDatastore/POSG.idn


BIN
OSiDatastore/SPO.dat


BIN
OSiDatastore/SPO.idn


BIN
OSiDatastore/SPOG.dat


BIN
OSiDatastore/SPOG.idn


+ 0 - 0
OSiDatastore/journal.jrnl


BIN
OSiDatastore/node2id.dat


BIN
OSiDatastore/node2id.idn


BIN
OSiDatastore/nodes.dat


BIN
OSiDatastore/prefix2id.dat


BIN
OSiDatastore/prefix2id.idn


BIN
OSiDatastore/prefixIdx.dat


BIN
OSiDatastore/prefixIdx.idn


BIN
OSiDatastore/prefixes.dat


+ 617 - 0
apache-jena-fuseki-3.12.0/LICENSE

@@ -0,0 +1,617 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+  (c) Copyright 2003, Plugged In Software 
+
+  All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+http://www.slf4j.org/license.html
+
+ Copyright (c) 2004-2011 QOS.ch
+ All rights reserved.
+
+ Permission is hereby granted, free  of charge, to any person obtaining
+ a  copy  of this  software  and  associated  documentation files  (the
+ "Software"), to  deal in  the Software without  restriction, including
+ without limitation  the rights to  use, copy, modify,  merge, publish,
+ distribute,  sublicense, and/or sell  copies of  the Software,  and to
+ permit persons to whom the Software  is furnished to do so, subject to
+ the following conditions:
+ 
+ The  above  copyright  notice  and  this permission  notice  shall  be
+ included in all copies or substantial portions of the Software.
+ 
+ THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+==============================================================
+ Jetty Web Container
+ Copyright 1995-2012 Mort Bay Consulting Pty Ltd.
+==============================================================
+
+The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
+unless otherwise noted.
+
+Jetty is dual licensed under both
+
+  * The Apache 2.0 License
+    http://www.apache.org/licenses/LICENSE-2.0.html
+
+      and
+
+  * The Eclipse Public 1.0 License
+    http://www.eclipse.org/legal/epl-v10.html
+
+Jetty may be distributed under either license.
+
+The javax.servlet package used was sourced from the Apache
+Software Foundation and is distributed under the apache 2.0
+license.
+
+The UnixCrypt.java code implements the one way cryptography used by
+Unix systems for simple password protection.  Copyright 1996 Aki Yoshida,
+modified April 2001  by Iris Van den Broeke, Daniel Deville.
+Permission to use, copy, modify and distribute UnixCrypt
+for non-commercial or commercial purposes and without fee is
+granted provided that the copyright notice appears in all copies.
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+This product bundles "Bootstrap", which is available under an
+MIT license.  See: https://github.com/twbs/bootstrap/blob/master/LICENSE
+
+This product bundles "codemirror", which is available under an
+MIT license.  See http://codemirror.net/LICENSE
+
+This product bundles "jquery", which is available under an
+MIT license.  See https://jquery.org/license/
+
+This product bundles "jquery.form", which is available under an
+MIT license.  See http://malsup.github.io/mit-license.txt
+
+This product bundles "jquery.xdomainrequest", which is available under an
+MIT license.  See https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest/blob/master/LICENSE.txt
+
+This product bundles "backbone.js", which is available under an
+MIT license.  See https://github.com/jashkenas/backbone/blob/master/LICENSE
+
+This product bundles "backbone.marionette", which is available under an
+MIT license. See http://mutedsolutions.mit-license.org/
+   "backbone.marionette" includes "Backbone.BabySitter" and 
+   "Backbone.Wreqr" also available under the same MIT license.
+
+This product bundles "html5shiv", which is available under an
+MIT license.  See https://code.google.com/p/html5shiv/
+
+This product bundles "RequireJS", which is available under an
+MIT license. 
+https://github.com/jrburke/requirejs/blob/master/LICENSE
+  "RequireJS" is also available with a "30clause BSD license"
+
+This product bundles "Respond", which is available under an
+MIT license. See https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
+
+This product bundles "sprintf.js", which is available under a
+"3 clause BSD" license. 
+  https://github.com/alexei/sprintf.js/blob/master/LICENSE
+
+This product bundles "underscore", which is available under an
+MIT license.  See https://github.com/jashkenas/underscore/blob/master/LICENSE
+
+This product bundles "FontAwesome"
+  "Font Awesome by Dave Gandy - http://fontawesome.io"
+The font is available under an  SIL Open Font License 1.1
+and the CSS files under an MIT License.
+See http://fontawesome.io/license/
+
+This product bundles "jQuery File Upload Plugin" 
+which is available under an MIT License.
+See https://github.com/blueimp/jQuery-File-Upload
+
+This product bundles "Bootstrap-select"
+which is available under an MIT License.
+See https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE
+
+This product bundles "pivot.js"
+which is available under a BSD 3-clause style license.
+https://github.com/rwjblue/pivot.js/blob/master/LICENSE
+
+This product bundles "YASEQE - Yet Another Sparql Query Editor"
+which is available under an MIT License.
+See http://yasqe.yasgui.org/license.txt
+
+This product bundles "YASR - Yet Another Sparql Resultset GUI"
+which is available under an MIT License.
+See http://yasr.yasgui.org/license.txt
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+From Apache HttpComponents Client
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls.
+See http://www.jcip.net and the Creative Commons Attribution License 
+(http://creativecommons.org/licenses/by/2.5)
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+From Apache Lucene
+
+Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was
+derived from unicode conversion examples available at
+http://www.unicode.org/Public/PROGRAMS/CVTUTF.  Here is the copyright
+from those sources:
+
+/*
+ * Copyright 2001-2004 Unicode, Inc.
+ * 
+ * Disclaimer
+ * 
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ * 
+ * Limitations on Rights to Redistribute This Code
+ * 
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+
+
+Some code in core/src/java/org/apache/lucene/util/ArrayUtil.java was
+derived from Python 2.4.2 sources available at
+http://www.python.org. Full license is here:
+
+  http://www.python.org/download/releases/2.4.2/license/
+
+Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was
+derived from Python 3.1.2 sources available at
+http://www.python.org. Full license is here:
+
+  http://www.python.org/download/releases/3.1.2/license/
+
+Some code in core/src/java/org/apache/lucene/util/automaton was
+derived from Brics automaton sources available at
+www.brics.dk/automaton/. Here is the copyright from those sources:
+
+/*
+ * Copyright (c) 2001-2009 Anders Moeller
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+The levenshtein automata tables in core/src/java/org/apache/lucene/util/automaton 
+were automatically generated with the moman/finenight FSA package.
+Here is the copyright for those sources:
+
+# Copyright (c) 2010, Jean-Philippe Barrette-LaPierre, <jpb@rrette.com>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was
+derived from ICU (http://www.icu-project.org)
+The full license is available here: 
+  http://source.icu-project.org/repos/icu/icu/trunk/license.html
+
+/*
+ * Copyright (C) 1999-2010, International Business Machines
+ * Corporation and others.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy 
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights 
+ * to use, copy, modify, merge, publish, distribute, and/or sell copies of the 
+ * Software, and to permit persons to whom the Software is furnished to do so, 
+ * provided that the above copyright notice(s) and this permission notice appear 
+ * in all copies of the Software and that both the above copyright notice(s) and
+ * this permission notice appear in supporting documentation.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE 
+ * LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR 
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall not 
+ * be used in advertising or otherwise to promote the sale, use or other 
+ * dealings in this Software without prior written authorization of the 
+ * copyright holder.
+ */
+ 
+The following license applies to the Snowball stemmers:
+
+Copyright (c) 2001, Dr Martin Porter
+Copyright (c) 2002, Richard Boulton
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+    * this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+    * notice, this list of conditions and the following disclaimer in the
+    * documentation and/or other materials provided with the distribution.
+    * Neither the name of the copyright holders nor the names of its contributors
+    * may be used to endorse or promote products derived from this software
+    * without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The following license applies to the KStemmer:
+
+Copyright © 2003,
+Center for Intelligent Information Retrieval,
+University of Massachusetts, Amherst.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+3. The names "Center for Intelligent Information Retrieval" and
+"University of Massachusetts" must not be used to endorse or promote products
+derived from this software without prior written permission. To obtain
+permission, contact info@ciir.cs.umass.edu.
+
+THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF MASSACHUSETTS AND OTHER CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+The following license applies to the Morfologik project:
+
+Copyright (c) 2006 Dawid Weiss
+Copyright (c) 2007-2011 Dawid Weiss, Marcin Miłkowski
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, 
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, 
+    this list of conditions and the following disclaimer.
+    
+    * Redistributions in binary form must reproduce the above copyright notice, 
+    this list of conditions and the following disclaimer in the documentation 
+    and/or other materials provided with the distribution.
+    
+    * Neither the name of Morfologik nor the names of its contributors 
+    may be used to endorse or promote products derived from this software 
+    without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+---
+
+The dictionary comes from Morfologik project. Morfologik uses data from 
+Polish ispell/myspell dictionary hosted at http://www.sjp.pl/slownik/en/ and 
+is licenced on the terms of (inter alia) LGPL and Creative Commons 
+ShareAlike. The part-of-speech tags were added in Morfologik project and
+are not found in the data from sjp.pl. The tagset is similar to IPI PAN
+tagset.
+
+---
+
+The following license applies to the Morfeusz project,
+used by org.apache.lucene.analysis.morfologik.
+
+BSD-licensed dictionary of Polish (SGJP)
+http://sgjp.pl/morfeusz/
+
+Copyright © 2011 Zygmunt Saloni, Włodzimierz Gruszczyński, 
+	    	 Marcin Woliński, Robert Wołosz
+
+All rights reserved.
+
+Redistribution and  use in  source and binary  forms, with  or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS “AS IS” AND ANY EXPRESS
+OR  IMPLIED WARRANTIES,  INCLUDING, BUT  NOT LIMITED  TO,  THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT  SHALL COPYRIGHT  HOLDERS OR  CONTRIBUTORS BE
+LIABLE FOR  ANY DIRECT,  INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES  (INCLUDING, BUT NOT LIMITED  TO, PROCUREMENT OF
+SUBSTITUTE  GOODS OR  SERVICES;  LOSS  OF USE,  DATA,  OR PROFITS;  OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF LIABILITY,
+WHETHER IN  CONTRACT, STRICT LIABILITY, OR  TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+

+ 216 - 0
apache-jena-fuseki-3.12.0/NOTICE

@@ -0,0 +1,216 @@
+Apache Jena - module Fuseki
+Copyright 2011-2019 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Portions of this software were originally based on the following:
+  - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP
+  - Copyright 2010, 2011 Epimorphics Ltd.
+  - Copyright 2010, 2011 Talis Systems Ltd.
+These have been licensed to the Apache Software Foundation under a software grant.
+
+- - - - - - - - - - - - - - - - - - - - - - - 
+
+slf4j:
+ Copyright (c) 2004-2011 QOS.ch
+ All rights reserved.
+
+- - - - - - - - - - - - - - - - - - - - - - -
+
+(c) Copyright 2003, Plugged In Software 
+This product includes software developed by
+PluggedIn Software under a BSD license.
+
+- - - - - - - - - - - - - - - - - - - - - - -
+
+ Jetty Web Container
+ Copyright 1995-2012 Mort Bay Consulting Pty Ltd.
+
+under the Apache 2.0 License. 
+
+The Jetty Web Container includes:
+
+UnixCrypt.java
+Copyright 1996 Aki Yoshida,
+modified April 2001  by Iris Van den Broeke, Daniel Deville.
+
+- - - - - - - - - - - - - - - - - - - - - - -
+
+From Apache HttpComponents Client:
+
+This project contains annotations derived from JCIP-ANNOTATIONS
+Copyright (c) 2005 Brian Goetz and Tim Peierls. See http://www.jcip.net
+
+- - - - - - - - - - - - - - - - - - - - - - -
+
+  Apache Xerces Java
+   Copyright 1999-2013 The Apache Software Foundation
+
+   This product includes software developed at
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Portions of this software were originally based on the following:
+     - software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
+     - software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
+     - voluntary contributions made by Paul Eng on behalf of the 
+       Apache Software Foundation that were originally developed at iClick, Inc.,
+       software copyright (c) 1999.
+
+- - - - - - - - - - - - - - - - - - - - - - -
+
+From Apache Lucene:
+
+ICU4J, (under analysis/icu) is licensed under an MIT styles license
+and Copyright (c) 1995-2008 International Business Machines Corporation and others
+
+Some data files (under analysis/icu/src/data) are derived from Unicode data such
+as the Unicode Character Database. See http://unicode.org/copyright.html for more
+details.
+
+Brics Automaton (under core/src/java/org/apache/lucene/util/automaton) is 
+BSD-licensed, created by Anders Møller. See http://www.brics.dk/automaton/
+
+The levenshtein automata tables (under core/src/java/org/apache/lucene/util/automaton) were
+automatically generated with the moman/finenight FSA library, created by
+Jean-Philippe Barrette-LaPierre. This library is available under an MIT license,
+see http://sites.google.com/site/rrettesite/moman and 
+http://bitbucket.org/jpbarrette/moman/overview/
+
+This product includes code (JaspellTernarySearchTrie) from Java Spelling 
+Checking Package (jaspell): http://jaspell.sourceforge.net/
+License: The BSD License (http://www.opensource.org/licenses/bsd-license.php)
+
+The snowball stemmers in
+  analysis/common/src/java/net/sf/snowball
+were developed by Martin Porter and Richard Boulton.
+The snowball stopword lists in
+  analysis/common/src/resources/org/apache/lucene/analysis/snowball
+were developed by Martin Porter and Richard Boulton.
+The full snowball package is available from
+  http://snowball.tartarus.org/
+
+The KStem stemmer in
+  analysis/common/src/org/apache/lucene/analysis/en
+was developed by Bob Krovetz and Sergio Guzman-Lara (CIIR-UMass Amherst)
+under the BSD-license.
+
+The Arabic,Persian,Romanian,Bulgarian, and Hindi analyzers (common) come with a default
+stopword list that is BSD-licensed created by Jacques Savoy.
+See http://members.unine.ch/jacques.savoy/clef/index.html.
+
+The German,Spanish,Finnish,French,Hungarian,Italian,Portuguese,Russian and Swedish light stemmers
+(common) are based on BSD-licensed reference implementations created by Jacques Savoy and
+Ljiljana Dolamic.
+
+The Stempel analyzer (stempel) includes BSD-licensed software developed 
+by the Egothor project http://egothor.sf.net/, created by Leo Galambos, Martin Kvapil,
+and Edmond Nolan.
+
+The Polish analyzer (stempel) comes with a default
+stopword list that is BSD-licensed created by the Carrot2 project. The file resides
+in stempel/src/resources/org/apache/lucene/analysis/pl/stopwords.txt.
+See http://project.carrot2.org/license.html.
+
+The SmartChineseAnalyzer source code (smartcn) was
+provided by Xiaoping Gao and copyright 2009 by www.imdict.net.
+
+WordBreakTestUnicode_*.java (under modules/analysis/common/src/test/) 
+is derived from Unicode data such as the Unicode Character Database. 
+See http://unicode.org/copyright.html for more details.
+
+The Morfologik analyzer (morfologik) includes BSD-licensed software
+developed by Dawid Weiss and Marcin Miłkowski (http://morfologik.blogspot.com/).
+
+Morfologik uses data from Polish ispell/myspell dictionary
+(http://www.sjp.pl/slownik/en/) licenced on the terms of (inter alia)
+LGPL and Creative Commons ShareAlike.
+
+Morfologic includes data from BSD-licensed dictionary of Polish (SGJP)
+(http://sgjp.pl/morfeusz/)
+
+Servlet-api.jar and javax.servlet-*.jar are under the CDDL license, the original
+source code for this can be found at http://www.eclipse.org/jetty/downloads.php
+
+===========================================================================
+Kuromoji Japanese Morphological Analyzer - Apache Lucene Integration
+===========================================================================
+
+This software includes a binary and/or source version of data from
+
+  mecab-ipadic-2.7.0-20070801
+
+which can be obtained from
+
+  http://atilika.com/releases/mecab-ipadic/mecab-ipadic-2.7.0-20070801.tar.gz
+
+or
+
+  http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz
+
+===========================================================================
+mecab-ipadic-2.7.0-20070801 Notice
+===========================================================================
+
+Nara Institute of Science and Technology (NAIST),
+the copyright holders, disclaims all warranties with regard to this
+software, including all implied warranties of merchantability and
+fitness, in no event shall NAIST be liable for
+any special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether in an
+action of contract, negligence or other tortuous action, arising out
+of or in connection with the use or performance of this software.
+
+A large portion of the dictionary entries
+originate from ICOT Free Software.  The following conditions for ICOT
+Free Software applies to the current dictionary as well.
+
+Each User may also freely distribute the Program, whether in its
+original form or modified, to any third party or parties, PROVIDED
+that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
+on, or be attached to, the Program, which is distributed substantially
+in the same form as set out herein and that such intended
+distribution, if actually made, will neither violate or otherwise
+contravene any of the laws and regulations of the countries having
+jurisdiction over the User or the intended distribution itself.
+
+NO WARRANTY
+
+The program was produced on an experimental basis in the course of the
+research and development conducted during the project and is provided
+to users as so produced on an experimental basis.  Accordingly, the
+program is provided without any warranty whatsoever, whether express,
+implied, statutory or otherwise.  The term "warranty" used herein
+includes, but is not limited to, any warranty of the quality,
+performance, merchantability and fitness for a particular purpose of
+the program and the nonexistence of any infringement or violation of
+any right of any third party.
+
+Each user of the program will agree and understand, and be deemed to
+have agreed and understood, that there is no warranty whatsoever for
+the program and, accordingly, the entire risk arising from or
+otherwise connected with the program is assumed by the user.
+
+Therefore, neither ICOT, the copyright holder, or any other
+organization that participated in or was otherwise related to the
+development of the program and their respective officials, directors,
+officers and other employees shall be held liable for any and all
+damages, including, without limitation, general, special, incidental
+and consequential damages, arising out of or otherwise in connection
+with the use or inability to use the program or any product, material
+or result produced or otherwise obtained by using the program,
+regardless of whether they have been advised of, or otherwise had
+knowledge of, the possibility of such damages at any time during the
+project or thereafter.  Each user will be deemed to have agreed to the
+foregoing by his or her commencement of use of the program.  The term
+"use" as used herein includes, but is not limited to, the use,
+modification, copying and distribution of the program and the
+production of secondary products from the program.
+
+In the case where the program, whether in its original form or
+modified, was distributed or delivered to or received by a user from
+any person, organization or entity other than ICOT, unless it makes or
+grants independently of ICOT any specific warranty to the user in
+writing, such person, organization or entity, will also be exempted
+from and not be held liable to the user for any such damages as noted
+above as far as the program is concerned.

+ 62 - 0
apache-jena-fuseki-3.12.0/README

@@ -0,0 +1,62 @@
+Apache Jena Fuseki2
+===================
+
+Apache Jena Fuseki2 is a SPARQL server.
+
+Full documentation:
+  http://jena.apache.org/documentation/fuseki2/
+
+This distribution contains Fuseki2 package as a WAR file ('fuseki.war'),
+to run in a webapp conatiner server such as Apache Tomcat, and also a
+self-contained jar, to run as a operation system process.
+
+The script 'fuseki' is an Linux init script to run Fuseki2 as a service.
+The file 'fuseki.service' is a systemd unit file to run Fuseki2 as a service.
+Instructions are in comments at the start of the files.
+
+The script 'fuseki-server' is a script to run the server using
+fuseki-server.jar from the command line.  Use 'fuseki-server --help' for
+details.
+
+The directory 'bin/' contains some scripts execute SPARQL Protocol and
+SPARQL Graph Store Protocol operations.
+Documentation: http://jena.apache.org/documentation/fuseki2/soh.html
+
+
+Cryptographic Software Notice
+-----------------------------
+
+This distribution includes cryptographic software. The country in which
+you currently reside may have restrictions on the import, possession,
+use, and/or re-export to another country, of encryption software. BEFORE
+using any encryption software, please check your country's laws,
+regulations and policies concerning the import, possession, or use, and
+re-export of encryption software, to see if this is permitted.
+See <http://www.wassenaar.org/> for more information.
+
+The U.S. Government Department of Commerce, Bureau of Industry and
+Security (BIS), has classified this software as Export Commodity
+Control Number (ECCN) 5D002.C.1, which includes information security
+software using or performing cryptographic functions with asymmetric
+algorithms. The form and manner of this Apache Software Foundation
+distribution makes it eligible for export under the License Exception
+ENC Technology Software Unrestricted (TSU) exception (see the BIS
+Export Administration Regulations, Section 740.13) for both object
+code and source code.
+
+The following provides more details on the included software that
+may be subject to export controls on cryptographic software:
+
+  Apache Jena Fuseki2 (distribution) includes
+     Apache HttpComponents Client 
+     Apache HttpComponents Core
+  which interfaces with the Java Secure Socket Extension (JSSE) API
+  and also 
+     Apache Shiro
+     Eclipse Jetty
+  to provide
+
+     - HTTPS support
+
+   Apache Jena Fuseki2 (distribution) does not include any
+   implementation of JSSE.

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-delete

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-get

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-head

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-post

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-put

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-query

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-update

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/s-update-form

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 725 - 0
apache-jena-fuseki-3.12.0/bin/soh

@@ -0,0 +1,725 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SPARQL HTTP Update, client.
+
+require 'optparse'
+require 'net/http'
+require 'openssl'
+require 'uri'
+require 'cgi'
+require 'pp'
+require 'ostruct'
+
+# ToDo
+#  Allow a choice of media type for GET
+#   --accept "content-type" (and abbreviations)
+#   --header "Add:this"
+#   --user, --password
+#  Basic authentication: request.basic_auth("username", "password")
+#  Follow redirects => 301:  puts response["location"] # All headers are lowercase?
+
+SOH_NAME="SOH"
+SOH_VERSION="1.0.0"
+
+$proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new  
+
+# What about direct naming?
+
+# Names
+$mtTurtle           = 'text/turtle;charset=utf-8'
+$mtRDF              = 'application/rdf+xml'
+$mtText             = 'text/plain'
+$mtNTriples         = 'application/n-triples'
+$mtNQuads           = 'application/n-quads'
+$mtJSONLD           = 'application/ld+json'
+$mtTriG             = 'application/trig'
+$mtSparqlResultsX   = 'application/sparql-results+xml'
+$mtSparqlResultsJ   = 'application/sparql-results+json'
+$mtAppJSON          = 'application/json'
+$mtAppXML           = 'application/xml'
+$mtSparqlResultsTSV = 'application/sparql-results+tsv'
+$mtSparqlResultsCSV = 'application/sparql-results+csv'
+$mtSparqlUpdate     = 'application/sparql-update'
+$mtWWWForm          = 'application/x-www-form-urlencoded'
+$mtSparqlQuery      = "application/sparql-query" ;
+
+# Global media type table.
+$fileMediaTypes = {}
+$fileMediaTypes['ttl']   = $mtTurtle
+$fileMediaTypes['n3']    = 'text/n3; charset=utf-8'
+$fileMediaTypes['nt']    = $mtText
+$fileMediaTypes['rdf']   = $mtRDF
+$fileMediaTypes['owl']   = $mtRDF
+$fileMediaTypes['nq']    = $mtNQuads
+$fileMediaTypes['trig']  = $mtTriG
+$fileMediaTypes['json-ld']  = $mtJSONLD
+$fileMediaTypes['jsonld']  = $mtJSONLD
+
+# Global charset : no entry means "don't set"
+$charsetUTF8      = 'utf-8'
+$charset = {}
+$charset[$mtTurtle]   = 'utf-8'
+$charset[$mtText]     = 'ascii'
+$charset[$mtTriG]     = 'utf-8'
+$charset[$mtNQuads]   = 'utf-8'
+
+# Headers
+
+$hContentType         = 'Content-Type'
+# $hContentEncoding     = 'Content-Encoding'
+$hContentLength       = 'Content-Length'
+# $hContentLocation     = 'Content-Location'
+# $hContentRange        = 'Content-Range'
+
+$hAccept              = 'Accept'
+$hAcceptCharset       = 'Accept-Charset'
+$hAcceptEncoding      = 'Accept-Encoding'
+$hAcceptRanges        = 'Accept-Ranges' 
+
+$headers = { "User-Agent" => "#{SOH_NAME}/Fuseki #{SOH_VERSION}"}
+$print_http = false
+
+# Default for GET
+# At least allow anything (and hope!)
+$accept_rdf="#{$mtTurtle} , #{$mtNTriples};q=0.9 , #{$mtRDF};q=0.8 , #{$mtJSONLD};q=0.5"
+# Datasets
+$accept_ds="#{$mtTrig} , #{$mtNQuads};q=0.9 , #{$mtJSONLD};q=0.5"
+# For SPARQL query
+$accept_results="#{$mtSparqlResultsJ} , #{$mtSparqlResultsX};q=0.9 , #{$accept_rdf}"
+
+# Accept any in case of trouble.
+$accept_rdf="#{$accept_rdf} , */*;q=0.1"
+$accept_results="#{$accept_results} , */*;q=0.1" 
+
+# The media type usually forces the charset.
+$accept_charset=nil
+
+## Who we are.
+## Two styles:
+##    s-query .....
+##    soh query .....
+
+$cmd = File.basename($0)
+if $cmd == 'soh'
+then
+  $cmd = (ARGV.size == 0) ? 'soh' : ARGV.shift
+end
+
+if ! $cmd.start_with?('s-') && $cmd != 'soh'
+  $cmd = 's-'+$cmd
+end
+
+## -------- 
+
+def GET(dataset, graph)
+  print "GET #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  get_worker(requestURI, headers)
+end
+
+def get_worker(requestURI, headers)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Get.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+def HEAD(dataset, graph)
+  print "HEAD #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  headers = {}
+  headers.merge!($headers)
+  headers[$hAccept] = $accept_rdf
+  headers[$hAcceptCharset] = $accept_charset unless $accept_charset.nil?
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Head.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def PUT(dataset, graph, file)
+  print "PUT #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Put)
+end
+
+def POST(dataset, graph, file)
+  print "POST #{dataset} #{graph} #{file}\n" if $verbose
+  send_body(dataset, graph, file, Net::HTTP::Post)
+end
+
+def DELETE(dataset, graph)
+  print "DELETE #{dataset} #{graph}\n" if $verbose
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  request = Net::HTTP::Delete.new(uri.request_uri)
+  headers = {}
+  headers.merge!($headers)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def uri_escape(string)
+  CGI.escape(string)
+end
+
+def target(dataset, graph)
+  return dataset+"?default" if graph == "default"
+  return dataset+"?graph="+uri_escape(graph)
+end
+
+def send_body(dataset, graph, file, method)
+  mt = content_type(file)
+  if mt.nil?
+    warn_exit "Can't identify the content type of '#{file}'", 9
+  end
+  headers = {}
+  headers.merge!($headers)
+  headers[$hContentType] = mt
+  headers[$hContentLength] = File.size(file).to_s
+  ## p headers
+
+  requestURI = target(dataset, graph)
+  uri = URI.parse(requestURI)
+  
+  request = method.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  print_http_request(uri, request)
+  request.body_stream = File.open(file)
+  response_no_body(uri, request)
+end
+
+def response_no_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  http.read_timeout = nil
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  
+  begin http.start do |http|
+      response = http.request(request)
+      print_http_response(response)
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code} #{response.message} #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e  
+    # puts e.message  
+    #puts e.backtrace.inspect  
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def response_print_body(uri, request)
+  http = Net::HTTP::Proxy($proxy.host,$proxy.port).new(uri.host, uri.port)
+  if uri.scheme == 'https'
+    http.use_ssl = uri.scheme == 'https'
+    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+  end
+  begin http.start do |http|
+      
+      # Add a blank line if headers were output.
+      print "\n" if $http_print ;
+
+      response = http.request(request) { |res| 
+        print_http_response(res)
+        #puts res.code
+        res.read_body do |segment|
+          print segment
+        end
+      }
+      case response
+      when Net::HTTPSuccess, Net::HTTPRedirection
+        # OK
+      when Net::HTTPNotFound
+        warn_exit "404 Not found: #{uri}", 9
+        #print response.body
+      else
+        warn_exit "#{response.code}: #{uri}", 9
+        # Unreachable
+        response.error!
+      end
+    end
+  rescue Exception => e
+    warn_exit "Failed to connect: #{uri.host}:#{uri.port}: #{e.message}", 3
+  end
+end
+
+def print_http_request(uri, request)
+  return unless $print_http
+  #print "Request\n"
+  print request.method," ",uri, "\n"
+  print_headers("  ",request)
+end
+
+def print_http_response(response)
+  return unless $print_http
+  #print "Response\n"
+  print response.code, " ", response.message, "\n"
+  print_headers("  ",response)
+end
+
+def print_headers(marker, headers)
+  headers.each do |k,v| 
+    k = k.split('-').map{|w| w.capitalize}.join('-')+':'
+    printf "%s%-20s %s\n",marker,k,v
+  end
+end
+
+def content_type(file)
+  file =~ /\.([^.]*)$/
+  ext = $1
+  mt = $fileMediaTypes[ext]
+  cs = $charset[mt]
+  mt = mt+';charset='+cs if ! cs.nil?
+  return mt
+end
+
+def charset(content_type)
+  return $charset[content_type]
+end
+
+def warn_exit(msg, rc)
+    warn msg
+    exit rc ;
+end
+
+def parseURI(uri_string)
+  begin
+    return URI.parse(uri_string).to_s
+  rescue URI::InvalidURIError => err
+    warn_exit "Bad URI: <#{uri_string}>", 2
+  end
+end
+
+## ---- Command
+
+def cmd_soh(command=nil)
+  ## Command line
+  options = {}
+  optparse = OptionParser.new do |opts|
+    # Set a banner, displayed at the top
+    # of the help screen.
+    case $cmd
+    when "s-http", "sparql-http", "soh"
+      banner="$cmd [get|post|put|delete] datasetURI graph [file]"
+    when "s-get", "s-head", "s-delete"
+      banner="$cmd  datasetURI graph"
+    end
+
+    opts.banner = $banner
+    # Define the options, and what they do
+    
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    
+    options[:version] = false
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end
+    
+    # This displays the help screen, all programs are
+    # assumed to have this option.
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  if command.nil?
+    if ARGV.size == 0
+      warn "No command given: expected one of 'get', 'put', 'post', 'delete', 'query' or 'update'"
+      exit 1
+    end
+    cmdPrint=ARGV.shift
+    command=cmdPrint.upcase
+  else
+    cmdPrint=command
+  end
+
+  case command
+  when "HEAD", "GET", "DELETE"
+    requiredFile=false
+  when "PUT", "POST"
+    requiredFile=true
+  when "QUERY"
+    cmd_sparql_query
+  when "UPDATE"
+    cmd_sparql_update
+  else
+    warn_exit "Unknown command: #{command}", 2
+  end
+
+  if requiredFile 
+  then
+    if ARGV.size != 3
+      warn_exit "Required: dataset URI, graph URI (or 'default') and file", 1 
+    end
+  else
+    if ARGV.size != 2
+      warn_exit "Required: dataset URI and graph URI (or 'default')", 1 
+    end
+  end
+
+  dataset=parseURI(ARGV.shift)
+  # Relative URI?
+  graph=parseURI(ARGV.shift)
+  file=""
+  if requiredFile
+  then
+    file = ARGV.shift if requiredFile
+    if ! File.exist?(file)
+      warn_exit "No such file: "+file, 3
+    end
+    if File.directory?(file)
+      warn_exit "File is a directory: "+file, 3
+    end
+  end
+
+  case command
+  when "GET"
+    GET(dataset, graph)
+  when "HEAD"
+    HEAD(dataset, graph)
+  when "PUT"
+    PUT(dataset, graph, file)
+  when "DELETE"
+    DELETE(dataset, graph)
+  when "POST"
+    POST(dataset, graph, file)
+  else
+    warn_exit "Internal error: Unknown command: #{cmd}", 2
+  end
+  exit 0
+end
+
+## --------
+def string_or_file(arg)
+  return arg if ! arg.match(/^@/)
+  a=(arg[1..-1])
+  open(a, 'rb'){|f| f.read}
+end
+
+## -------- SPARQL Query
+
+## Choose method
+def SPARQL_query(service, query, query_file, forcePOST=false, args2={})
+   if ! query_file.nil?
+    query = open(query_file, 'rb'){|f| f.read}
+  end
+  if forcePOST || query.length >= 2*1024 
+    SPARQL_query_POST(service, query, args2)
+  else
+    SPARQL_query_GET(service, query, args2)
+  end
+end
+
+## By GET
+
+def SPARQL_query_GET(service, query, args2)
+  args = { "query" => query }
+  args.merge!(args2)
+  qs=args.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+
+  if service.include? "?"
+  then
+    action="#{service}&#{qs}"
+  else
+    action="#{service}?#{qs}"
+  end
+
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  get_worker(action, headers)
+end
+
+## By POST
+
+def SPARQL_query_POST(service, query, args2)
+  # DRY - body/no body for each of request and response.
+  post_params={ "query" => query }
+  post_params.merge!(args2)
+  uri = URI.parse(service)
+  headers={}
+  headers.merge!($headers)
+  headers[$hAccept]=$accept_results
+  execute_post_form_body(uri, headers, post_params)
+end
+
+def execute_post_form_body(uri, headers, post_params)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  qs=post_params.collect { |k,v| "#{k}=#{uri_escape(v)}" }.join('&')
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = qs.length.to_s
+  request.initialize_http_header(headers)
+  request.body = qs
+  print_http_request(uri, request)
+  response_print_body(uri, request)
+end
+
+# Usage: -v --help --file= --query=
+def cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--query QUERY] [--service URI] [--post] 'query' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--query=FILE','--file=FILE', 'Take query from a file') do |file|
+      options[:file]=file
+    end
+    opts.on('--output=TYPE', [:json,:xml,:text,:csv,:tsv],
+            'Set the output argument') do |type|
+      options[:output]=type
+    end
+    opts.on('--accept=TYPE', [:json,:xml,:text,:csv,:tsv], 
+            'Set the accept header type') do |type|
+      options[:accept]=type
+    end
+    options[:verbose] = false
+    opts.on( '--post', 'Force use of POST' ) do
+      options[:post] = true
+    end
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
+    warn e
+    exit 1
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+  usePOST = options[:post]
+
+  service = options[:service]
+  warn_exit 'No service specified.  Required --service=URI',1 if service.nil?
+
+  # Query
+  query=nil
+  query_file=options[:file]
+  if query_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No query specified.',1
+    end
+  if query_file.nil?
+    query = ARGV.shift
+    if query.match(/^@/)
+      query_file = query[1..-1]
+      query = nil
+    end
+  end
+
+  # --output ==> output= (non-standard)
+  args={}
+  case options[:output]
+  when nil
+  when  "json","xml","text","csv","tsv"
+    args['output'] = options[:output]
+  when :json,:xml,:text,:csv,:tsv
+    args['output'] = options[:output].to_s
+  else
+    warn_exit "Unrecognized output type: "+options[:output],2
+  end
+
+  # --accept
+  # options[:accept]
+
+  print "SPARQL #{service}\n" if $verbose
+  #args={"output"=>"text"}
+  SPARQL_query(service, query, query_file, usePOST, args)
+  exit(0)
+end
+
+## -------- SPARQL Update
+
+# Update sent as a WWW form.
+def SPARQL_update_by_form(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  # args? encode?
+  body="update="+uri_escape(update)
+  headers[$hContentType] = $mtWWWForm
+  headers[$hContentLength] = body.length.to_s
+  uri = URI.parse(service)
+  execute_post_form(uri, headers, body)
+end
+
+# DRY - query form.
+def execute_post_form(uri, headers, body)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = body
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def SPARQL_update(service, update, args2={})
+  args = {}
+  args.merge!(args2)
+  headers={}
+  headers.merge!($headers)
+  headers[$hContentType] = $mtSparqlUpdate
+  uri = URI.parse(service)
+  request = Net::HTTP::Post.new(uri.request_uri)
+  request.initialize_http_header(headers)
+  request.body = update
+  print_http_request(uri, request)
+  response_no_body(uri, request)
+end
+
+def cmd_sparql_update(by_raw_post=true)
+  # Share with cmd_sparql_query
+  options={}
+  optparse = OptionParser.new do |opts|
+    opts.banner = "Usage: #{$cmd} [--file REQUEST] [--service URI] 'request' | @file"
+    opts.on('--service=URI', '--server=URI', 'SPARQL endpoint') do |uri|
+      options[:service]=uri
+    end
+    opts.on('--update=FILE', '--file=FILE', 'Take update from a file') do |file|
+      options[:file]=file
+    end
+    options[:verbose] = false
+    opts.on( '-v', '--verbose', 'Verbose' ) do
+      options[:verbose] = true
+    end
+    opts.on( '--version', 'Print version and exit' ) do
+      print "#{SOH_NAME} #{SOH_VERSION}\n"
+      exit
+    end 
+    opts.on( '-h', '--help', 'Display this screen and exit' ) do
+      puts opts
+      exit
+    end
+  end
+
+  begin optparse.parse!    
+  rescue OptionParser::InvalidArgument => e
+    warn e
+    exit
+  end
+
+  $verbose = options[:verbose]
+  $print_http = $verbose
+
+  service = options[:service]
+  warn_exit 'No service specified. Required --service=URI',1   if service.nil?
+  
+  update=nil
+  update_file=options[:file]
+
+  if update_file.nil? && ARGV.size == 0
+  then
+    warn_exit 'No update specified.',1
+    end
+  if update_file.nil?
+    update = ARGV.shift
+    if update.match(/^@/)
+      update_file = update[1..-1]
+      update = nil
+    end
+  end
+  
+  print "SPARQL-Update #{service}\n" if $verbose
+  args={}
+
+  # Reads in the file :-(
+  if update.nil?
+  then
+    update = open(update_file, 'rb'){|f| f.read}
+  else
+    update = string_or_file(update)
+  end
+
+  if by_raw_post
+    SPARQL_update(service, update, args)
+  else
+    SPARQL_update_by_form(service, update, args)
+  end
+  exit(0)
+end
+
+## -------
+
+case $cmd
+when "s-http", "sparql-http", "soh"
+  $banner="#{$cmd} [get|post|put|delete] datasetURI graph [file]"
+  cmd_soh
+when "s-get", "s-head", "s-put", "s-delete", "s-post"
+
+  case $cmd
+  when "s-get", "s-head", "s-delete"
+    $banner="#{$cmd} datasetURI graph"
+  when "s-put", "s-post"
+    $banner="#{$cmd} datasetURI graph file"
+  end
+  cmd2 = $cmd.sub(/^s-/, '').upcase
+  cmd_soh cmd2
+
+when "s-query", "sparql-query"
+  cmd_sparql_query
+when "s-update", "sparql-update"
+  cmd_sparql_update true
+when "s-update-form", "sparql-update-form"
+  cmd_sparql_update false
+else 
+  warn_exit "Unknown: "+$cmd, 1
+end

+ 512 - 0
apache-jena-fuseki-3.12.0/fuseki

@@ -0,0 +1,512 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# =========
+#
+# Startup script for Fuseki under *nix systems (works with cygwin too)
+#
+# Configuration
+# -------------
+# Values are loaded from /etc/default/fuseki, if it exists.
+# The description below cover the default settings if /etc/default/fuseki
+# does not exist.
+#
+# Set DEBUG=1 (see below or set the environment variable) to print the
+# settings to be used.
+#
+# JAVA
+#   Command to invoke Java. If not set, java (from the PATH) will be used.
+#   JAVA_HOME can also be used to set JAVA.
+#
+# JAVA_OPTIONS
+#   Extra options to pass to the JVM.
+#
+# FUSEKI_HOME
+#   Where Fuseki is installed.  If not set, the script will try
+#   to guess it based on the script invokation path.
+# 
+# FUSEKI_BASE
+#   The root of the runtime area - logs files, system files, local configuration.
+#   Defaults to $FUSEKI_HOME/run.
+#
+# FUSEKI_RUN
+#   Where the fuseki.pid file should be stored.  It defaults
+#   first available of /var/run, /usr/var/run, $FUSEKI_HOME and /tmp if not set.
+#
+# FUSEKI_PID
+#   The FUSEKI PID file, defaults to $FUSEKI_RUN/fuseki.pid
+#
+# FUSEKI_ARGS
+#   The arguments to pass to the Fuseki server on the command line. Defaults to:
+#                                        # if FUSEKI_CONF is not set
+#    --config=$FUSEKI_CONF               # if FUSEKI_CONF is set
+#
+# FUSEKI_START
+#   Path to the jar file. Defaults to $FUSEKI_HOME/fuseki-server.jar 
+#
+# FUSEKI_CLASSES
+#   Path to extra jars to add to the class path.  Defaults to none
+#   Should be of the form path/class.jar:path/class2.jar
+#
+# FUSEKI_CONF
+#   The Fuseki configuration file, usually in RDF Turtle notation.
+#
+# FUSEKI_USER
+#   If set, the server will be run as this user
+#
+# FUSEKI_LOGS
+#   Directory where logs will be generated. 
+#   Fixed as $FUSEKI_BASE/logs.
+#
+# FUSEKI_LOGS_STDERROUT
+#   Log file with stderr and stdout log output from Fuseki. 
+#   Defaults to $FUSEKI_LOGS/stderrout.log
+
+
+### BEGIN INIT INFO
+# Provides:          fuseki
+# Required-Start:    $remote_fs $network
+# Required-Stop:     $remote_fs $network
+# Default-Start:     3 4 5
+# Default-Stop:      0 1 2 6
+# Short-Description: Start Jena Fuseki at boot time
+# Description:       Jena Fuseki is a service that provides a SPARQL API over HTTP
+### END INIT INFO
+
+# DEBUG=1
+NAME=fuseki
+if [ -f /etc/default/$NAME ]; then
+  . /etc/default/$NAME
+fi
+
+# simple replacements for LSB daemon logging functions if not defined
+# Centos 6 has init-functions but not log_daemon_msg/log_begin_msg/log_end_msg
+# Define simple version - attempt to replace with /lib/lsb/init-functions
+log_daemon_msg() {
+    echo $1
+}
+log_begin_msg() {
+    echo $1
+}
+log_end_msg() {
+    if [ $1 -eq 0 ]; then
+	echo '[OK]'
+    else
+	echo '[failed]'
+    fi
+}
+
+if [ -f /lib/lsb/init-functions ]; then
+    . /lib/lsb/init-functions
+fi
+
+usage()
+{
+  echo "Usage: ${0##*/} {start|stop|restart|run|status}"
+  exit 1
+}
+
+[ $# -gt 0 ] || usage
+CMD="$1"
+
+# Utility functions
+
+findDirectory()
+{
+  local L OP=$1
+  shift
+  for L in "$@"; do
+    [ "$OP" "$L" ] || continue
+    printf %s "$L"
+    break
+  done
+}
+
+findFile()
+{
+  local L F=$1
+  shift
+  for L in "$@"; do
+    [ -f "${L}/${F}" ] || continue
+    printf %s "${L}/${F}"
+    break
+  done
+}
+
+running()
+{
+  local PID=$(cat "$1" 2>/dev/null) || return 1
+  ps -p "$PID" >/dev/null 2>&1
+}
+
+# Are we running in cygwin?
+cygwin=false
+case "`uname`" in
+    CYGWIN*) cygwin=true;;
+esac
+
+# Set FUSKEI_HOME to the script invocation directory if it is not specified
+if [ -z "$FUSEKI_HOME" ]
+then
+  SCRIPT="$0"
+  # Catch common issue: script has been symlinked
+  if [ -L "$SCRIPT" ]
+  then
+    SCRIPT="$(readlink "$0")"
+    # If link is relative
+    case "$SCRIPT" in
+      /*) ;; # fine
+      *) SCRIPT=$( dirname "$0" )/$SCRIPT;; # fix
+    esac
+  fi
+  # Work out root from script location
+  FUSEKI_HOME="$( cd "$( dirname "$SCRIPT" )" && pwd )"
+fi
+
+# Deal with Cygwin path issues
+if [ "$cygwin" == "true" ]
+then
+  FUSEKI_HOME=`cygpath -w "$FUSEKI_HOME"`
+fi
+
+if [ ! -e "$FUSEKI_HOME" ]
+then
+  log_daemon_msg "FUSEKI_HOME '$FUSEKI_HOME' does not exist" 1>&2
+  exit 1
+fi
+
+# Set FUSEKI_BASE
+if [ -z "$FUSEKI_BASE" ]
+then
+  #FUSEKI_BASE="/etc/fuseki"
+  FUSEKI_BASE="$FUSEKI_HOME/run"
+  # Autocreate FUSEKI_BASE if defaulting to FUSEKI_HOME/run (simple deployment)
+  if [ ! -e "$FUSEKI_BASE" ]
+  then
+      log_daemon_msg "Creating '$FUSEKI_BASE'"
+      if [ "$cygwin" == "true" ]
+      then
+	  FUSEKI_BASE=`cygpath -w "$FUSEKI_BASE"`
+      fi
+      mkdir "$FUSEKI_BASE"
+  fi
+fi
+
+if [ "$cygwin" == "true" ]
+then
+  FUSEKI_BASE=`cygpath -w "$FUSEKI_BASE"`
+fi
+
+if [ ! -e "$FUSEKI_BASE" -o ! -d "$FUSEKI_BASE" ]
+then
+  log_daemon_msg "FUSEKI_BASE '$FUSEKI_BASE' does not exist or is not a directory" 1>&2
+  exit 1
+fi
+
+if [ ! -w "$FUSEKI_BASE" ]
+then
+  log_daemon_msg "FUSEKI_BASE '$FUSEKI_BASE' is not writable." 1>&2
+  exit 1
+fi
+
+# Find a location for the pid file
+if [ -z "$FUSEKI_RUN" ]
+then
+  FUSEKI_RUN=$(findDirectory -w /var/run /usr/var/run $FUSEKI_HOME /tmp)
+fi
+
+# Get PID file name
+if [ -z "$FUSEKI_PID" ]
+then
+  FUSEKI_PID="$FUSEKI_RUN/fuseki.pid"
+fi
+
+# Log directory
+if [ -n "$FUSEKI_LOGS" ]
+then
+    log_daemon_message "FUSEKI_LOGS can not be set externally - ignored" 1>&2
+fi
+FUSEKI_LOGS="$FUSEKI_BASE/logs"
+
+# Stderr and stdout log
+if [ -z "$FUSEKI_LOGS_STDERROUT" ]
+then
+  FUSEKI_LOGS_STDERROUT="$FUSEKI_LOGS/stderrout.log"
+fi
+
+# Set up JAVA if not set
+if [ -z "$JAVA" ]
+then
+    if [ -z "$JAVA_HOME" ]
+    then
+       JAVA=$(which java)
+    else
+        JAVA=$JAVA_HOME/bin/java
+    fi
+fi
+
+if [ -z "$JAVA" ]
+then
+    (
+	echo "Cannot find a Java JDK."
+	echo "Please set either set JAVA or JAVA_HOME and put java (>=1.8) in your PATH."
+    ) 1>&2
+    exit 1
+fi
+
+# The location of the start up JAR
+FUSEKI_START=${FUSEKI_START:-$FUSEKI_HOME/fuseki-server.jar}
+
+# Deal with Cygwin path issues
+if [ "$cygwin" == "true" ]
+then
+  FUSEKI_START=`cygpath -w "$FUSEKI_START"`
+fi
+
+# Some JVM settings
+if [ -z "$JAVA_OPTIONS" ]
+then
+  JAVA_OPTIONS="-Xmx1200M"
+fi
+
+# Default Fuseki Arguments
+if [ -z "$FUSEKI_ARGS" ]
+then
+  if [ -z "$FUSEKI_CONF" ]
+  then
+    FUSEKI_ARGS=""
+  else
+    FUSEKI_ARGS="--config=$FUSEKI_CONF"
+  fi
+fi
+
+# Run command
+
+if [ -z "$FUSEKI_CLASSES" ]
+then
+  RUN_ARGS=(${JAVA_OPTIONS[@]} -jar "$FUSEKI_START" "${FUSEKI_ADDITIONAL_ARGS[@]}" $FUSEKI_ARGS)
+else
+  RUN_ARGS=(${JAVA_OPTIONS[@]} -cp "$FUSEKI_START:$FUSEKI_CLASSES" org.apache.jena.fuseki.cmd.FusekiCmd "${FUSEKI_ADDITIONAL_ARGS[@]}" $FUSEKI_ARGS)
+fi
+RUN_CMD=("$JAVA" "${RUN_ARGS[@]}")
+
+# Export the variables to be seen by the java server process.
+export FUSEKI_HOME
+export FUSEKI_BASE
+
+#####################################################
+# Comment these out after you're happy with what
+# the script is doing.
+#####################################################
+if (( DEBUG ))
+then
+  log_daemon_msg "FUSEKI_HOME    =  $FUSEKI_HOME"
+  log_daemon_msg "FUSEKI_BASE    =  $FUSEKI_BASE"
+  log_daemon_msg "FUSEKI_CONF    =  $FUSEKI_CONF"
+  log_daemon_msg "FUSEKI_RUN     =  $FUSEKI_RUN"
+  log_daemon_msg "FUSEKI_PID     =  $FUSEKI_PID"
+  log_daemon_msg "FUSEKI_ARGS    =  $FUSEKI_ARGS"
+  log_daemon_msg "FUSEKI_START   =  $FUSEKI_START"
+  log_daemon_msg "FUSEKI_CLASSES =  $FUSEKI_CLASSES"
+  log_daemon_msg "CONFIGS        =  ${CONFIGS[*]}"
+  log_daemon_msg "JAVA           =  $JAVA"
+  log_daemon_msg "JAVA_OPTIONS   =  ${JAVA_OPTIONS[*]}"
+  log_daemon_msg "RUN_ARGS       =  ${RUN_ARGS[@]}"
+  log_daemon_msg "RUN_CMD        =  ${RUN_CMD[@]}"
+  log_daemon_msg "Stdout/stderr  =  $FUSEKI_LOGS_STDERROUT"
+fi
+
+NO_START=${NO_START:-0}
+
+# Life cycle functions
+start() {
+  if (( NO_START )); then
+    log_daemon_msg "Not starting Fuseki - NO_START=1"
+    exit
+  fi
+
+  # Make sure the data and log directories exist
+  mkdir -p "$FUSEKI_LOGS"
+  if [ ! -z "$FUSEKI_USER" ]
+  then
+    chown "$FUSEKI_USER" "$FUSEKI_LOGS"
+  fi
+
+  # Make sure the .jar file exists
+  if [ ! -e $FUSEKI_START ]; then
+    log_daemon_msg "Could not see Fuseki .jar file: \$FUSEKI_START has value '$FUSEKI_START'"
+    exit 1
+  fi
+
+  log_begin_msg "Starting Fuseki"
+  if type start-stop-daemon > /dev/null 2>&1
+  then
+    unset CH_USER
+    if [ -n "$FUSEKI_USER" ]
+    then
+      CH_USER="--chuid $FUSEKI_USER"
+    fi
+    if start-stop-daemon --start $CH_USER --chdir "$FUSEKI_HOME" --background --make-pidfile --pidfile "$FUSEKI_PID" --startas /bin/bash -- -c "exec $JAVA ${RUN_ARGS[*]} > $FUSEKI_LOGS_STDERROUT 2>&1"
+    then
+      sleep 2
+      if running "$FUSEKI_PID"
+      then
+        log_end_msg 0
+        print_started
+      else
+        log_end_msg 1
+      fi
+    else
+      log_end_msg 1
+      log_daemon_msg "** start-stop-daemon failed to run"
+    fi
+  else
+    if running $FUSEKI_PID
+    then
+      log_end_msg 1
+      log_daemon_msg 'Already Running!'
+      exit 1
+    else
+      # dead pid file - remove
+      rm -f "$FUSEKI_PID"
+    fi
+
+# use subshell to cd to FUSKEI_HOME directory and execute
+    (cd "$FUSEKI_HOME"
+    if [ "$FUSEKI_USER" ]
+    then
+      touch "$FUSEKI_PID"
+      chown "$FUSEKI_USER" "$FUSEKI_PID"
+##       if [  "$FUSEKI_LOGS_STDERROUT" != "$FUSEKI_LOGS/stderrout.log" ]]
+##       then
+## 	  log_daemon_msg "Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT"
+##       fi
+      ## su with login, passing over environment variables.
+      su - "$FUSEKI_USER" -c "
+        export FUSEKI_BASE='${FUSEKI_BASE}'
+        export FUSEKI_HOME='${FUSEKI_HOME}'
+        exec ${RUN_CMD[*]} &> '$FUSEKI_LOGS_STDERROUT' &
+        disown \$!
+        echo \$! > '$FUSEKI_PID'"
+    else
+      exec "${RUN_CMD[@]}" &> "$FUSEKI_LOGS_STDERROUT" &
+      disown $!
+      echo $! > "$FUSEKI_PID"
+    fi
+)
+    
+    log_end_msg 0
+    print_started
+  fi
+}
+
+print_started() {
+  log_daemon_msg "STARTED Fuseki `date`"
+  log_daemon_msg "PID=$(cat "$FUSEKI_PID" 2>/dev/null)"
+}
+
+delete_fuseki_pid_file() {
+  rm -f "$FUSEKI_PID"
+}
+
+stop() {
+  log_begin_msg "Stopping Fuseki: "
+
+  if ! running "$FUSEKI_PID"
+  then
+    log_end_msg 1
+
+    # if a stop rather than a restart, signal failure to stop
+    if [ -z "$1" ]
+    then
+      exit 1
+    fi
+  fi
+
+  ###############################################################
+  # !!!! This code needs to be improved, too many repeats !!!!  #
+  ###############################################################
+  if type start-stop-daemon > /dev/null 2>&1; then
+    start-stop-daemon --stop --pidfile "$FUSEKI_PID" --chdir "$FUSEKI_HOME" --startas "$JAVA" --signal HUP
+
+    ## Die after a 30 second timeout
+    TIMEOUT=30
+    while running "$FUSEKI_PID"; do
+      if (( TIMEOUT-- == 0 )); then
+        start-stop-daemon --stop --pidfile "$FUSEKI_PID" --chdir "$FUSEKI_HOME" --startas "$JAVA" --signal KILL
+      fi
+        sleep 1
+    done
+    delete_fuseki_pid_file
+    log_end_msg 0
+  else
+    PID=$(cat "$FUSEKI_PID" 2>/dev/null)
+    kill "$PID" 2>/dev/null
+
+    TIMEOUT=30
+    while running $FUSEKI_PID; do
+      if (( TIMEOUT-- == 0 )); then
+        kill -KILL "$PID" 2>/dev/null
+      fi
+      sleep 1
+    done
+    delete_fuseki_pid_file
+    log_end_msg 0
+  fi
+}
+
+
+# Run in the foreground, as the current user
+run() {
+  # Make sure the .jar file exists
+  if [ ! -e $FUSEKI_START ]; then
+    log_daemon_msg "Could not see Fuseki .jar file: \$FUSEKI_START has value '$FUSEKI_START'"
+    exit 1
+  fi
+  exec "${RUN_CMD[@]}"
+}
+
+case $CMD in
+  start)
+    start
+  ;;
+  stop)
+    stop
+  ;;
+  restart)
+    stop "restarting"
+    start
+  ;;
+  run)
+    run
+  ;;
+  status)
+    if running $FUSEKI_PID
+    then
+      PID=`cat "$FUSEKI_PID"`
+      log_daemon_msg "Fuseki is running with pid: $PID"
+    else
+      log_daemon_msg "Fuseki is not running"
+    fi
+  ;;
+  *)
+    usage
+  ;;
+esac
+
+exit 0

+ 34 - 0
apache-jena-fuseki-3.12.0/fuseki-backup

@@ -0,0 +1,34 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Simple backup script for Fuseki - adapt as needed.
+# You may need to set the URL for example.
+# This script trigger the backup. It does not wait for it to complete.
+# Backups are placed in the /backups/ directory.
+
+if [[ $# != 1 ]]
+then
+    echo "Usage : $(basename $0) NAME" 1>&2
+    exit 1
+fi
+
+NAME="$1"
+
+curl -XPOST "http://localhost:3030/\$/backup/${NAME}"
+
+# You can track the background task with:
+#curl 'http://localhost:3030/$/tasks'

+ 95 - 0
apache-jena-fuseki-3.12.0/fuseki-server

@@ -0,0 +1,95 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Run fuseki as a standalone server
+
+export FUSEKI_HOME="${FUSEKI_HOME:-$PWD}"
+
+if [ ! -e "$FUSEKI_HOME" ]
+then
+    echo "$FUSEKI_HOME does not exist" 1>&2
+    exit 1
+    fi
+
+JAR1="$FUSEKI_HOME/fuseki-server.jar"
+JAR2="$FUSEKI_HOME/jena-fuseki-server-*.jar"
+JAR=""
+
+for J in "$JAR1" "$JAR2"
+do
+    # Expand
+    J="$(echo $J)"
+    if [ -e "$J" ]
+    then
+	JAR="$J"
+	break
+    fi
+done
+
+if [ "$JAR" = "" ]
+then
+    echo "Can't find jarfile to run"
+    exit 1
+fi
+
+# Deal with Cygwin path issues
+cygwin=false
+case "`uname`" in
+    CYGWIN*) cygwin=true;;
+esac
+if [ "$cygwin" = "true" ]
+then
+    JAR=`cygpath -w "$JAR"`
+    FUSEKI_HOME=`cygpath -w "$FUSEKI_HOME"`
+fi
+
+export FUSEKI_BASE="${FUSEKI_BASE:-$PWD/run}"
+
+if [ -z "$JAVA" ]
+then
+    if [ -z "$JAVA_HOME" ]
+    then
+       JAVA=$(which java)
+    else
+        JAVA=$JAVA_HOME/bin/java
+    fi
+fi
+
+if [ -z "$JAVA" ]
+then
+    (
+	echo "Cannot find a Java JDK."
+	echo "Please set either set JAVA or JAVA_HOME and put java (>=1.8) in your PATH."
+    ) 1>&2
+  exit 1
+fi
+
+JVM_ARGS=${JVM_ARGS:--Xmx1200M}
+
+exec $JAVA $JVM_ARGS -jar "$JAR" "$@"
+
+## Adding custom code to the Fuseki server:
+##
+## It is also possible to launch Fuseki using 
+##   java $JVM_ARGS -cp "$JAR" org.apache.jena.fuseki.cmd.FusekiCmd "$@"
+##
+## "exec" is optional - it simply frees up an OS process.
+## In this way, you can add custom java to the classpath:
+## 
+##   APPJAR=MyCode.jar
+##   java $JVM_ARGS -cp "$JAR:$APPJAR" org.apache.jena.fuseki.cmd.FusekiCmd "$@"
+

+ 28 - 0
apache-jena-fuseki-3.12.0/fuseki-server.bat

@@ -0,0 +1,28 @@
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM     http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+@REM modify this to name the server jar
+java -Xmx1200M -jar fuseki-server.jar %*
+
+@REM Adding custom code to the Fuseki server:
+@REM  
+@REM It is also possible to launch Fuseki using 
+@REM   java ..jvmarsg... -cp $JAR org.apache.jena.fuseki.cmd.FusekiCmd %*
+@REM 
+@REM In this way, you can add custom java to the classpath:
+@REM 
+@REM  java ... -cp fuseki-server.jar;MyCustomCode.jar org.apache.jena.fuseki.cmd.FusekiCmd %*

BIN
apache-jena-fuseki-3.12.0/fuseki-server.jar


+ 59 - 0
apache-jena-fuseki-3.12.0/fuseki.service

@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# =========
+#
+# Fuseki service configuration / unit file for systemd
+#
+# Usage:
+# ------
+#
+# 1. Place this file under /etc/systemd/system/
+# 2. Create a system user called "fuseki" and make sure it has permission
+#    to access the Fuseki configuration and databases
+# 3. Adjust the paths and other settings below if necessary
+# 4. Activate using: sudo systemctl enable fuseki.service
+
+[Unit]
+Description=Fuseki
+
+[Service]
+# Edit environment variables to match your installation
+Environment=FUSEKI_HOME=/opt/fuseki
+Environment=FUSEKI_BASE=/etc/fuseki
+# Edit the line below to adjust the amount of memory allocated to Fuseki
+Environment=JVM_ARGS=-Xmx2G
+# Edit to match your installation
+ExecStart=/opt/fuseki/fuseki-server
+# Run as user "fuseki"
+User=fuseki
+Restart=on-abort
+# Java processes exit with status 143 when terminated by SIGTERM, this
+# should be considered a successful shutdown
+SuccessExitStatus=143
+### By default, the service logs to journalctl only.
+### If additional logging to a file is required, uncomment the following three lines
+# StandardOutput=syslog
+# StandardError=syslog
+# SyslogIdentifier=fuseki
+### This logs to syslog. If, e.g., rsyslogd is used, you can provide a file
+### /etc/rsyslog.d/fuseki.conf, consisting of the following two lines (uncommented)
+### if $programname == 'fuseki' then /var/log/fuseki/stderrout.log
+### if $programname == 'fuseki' then stop
+
+
+[Install]
+WantedBy=multi-user.target

BIN
apache-jena-fuseki-3.12.0/fuseki.war


+ 30 - 0
apache-jena-fuseki-3.12.0/run/config.ttl

@@ -0,0 +1,30 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+## Fuseki Server configuration file.
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+[] rdf:type fuseki:Server ;
+   # Example::
+   # Server-wide query timeout.   
+   # 
+   # Timeout - server-wide default: milliseconds.
+   # Format 1: "1000" -- 1 second timeout
+   # Format 2: "10000,60000" -- 10s timeout to first result, 
+   #                            then 60s timeout for the rest of query.
+   #
+   # See javadoc for ARQ.queryTimeout for details.
+   # This can also be set on a per dataset basis in the dataset assembler.
+   #
+   # ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "30000" ] ;
+
+   # Add any custom classes you want to load.
+   # Must have a "public static void init()" method.
+   # ja:loadClass "your.code.Class" ;   
+
+   # End triples.
+   .

+ 38 - 0
apache-jena-fuseki-3.12.0/run/shiro.ini

@@ -0,0 +1,38 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+[main]
+# Development
+ssl.enabled = false 
+
+plainMatcher=org.apache.shiro.authc.credential.SimpleCredentialsMatcher
+#iniRealm=org.apache.shiro.realm.text.IniRealm 
+iniRealm.credentialsMatcher = $plainMatcher
+
+localhostFilter=org.apache.jena.fuseki.authz.LocalhostFilter
+
+[users]
+# Implicitly adds "iniRealm =  org.apache.shiro.realm.text.IniRealm"
+admin=pw
+
+[roles]
+
+[urls]
+## Control functions open to anyone
+/$/status  = anon
+/$/ping    = anon
+/$/metrics = anon
+
+## and the rest are restricted to localhost.
+/$/** = localhostFilter
+
+## If you want simple, basic authentication user/password
+## on the operations, 
+##    1 - set a better password in [users] above.
+##    2 - comment out the "/$/** = localhost" line and use:
+## "/$/** = authcBasic,user[admin]"
+
+## or to allow any access.
+##/$/** = anon
+
+# Everything else
+/**=anon

BIN
apache-jena-fuseki-3.12.0/run/system/GOSP.dat


BIN
apache-jena-fuseki-3.12.0/run/system/GOSP.idn


BIN
apache-jena-fuseki-3.12.0/run/system/GPOS.dat


BIN
apache-jena-fuseki-3.12.0/run/system/GPOS.idn


BIN
apache-jena-fuseki-3.12.0/run/system/GSPO.dat


BIN
apache-jena-fuseki-3.12.0/run/system/GSPO.idn


BIN
apache-jena-fuseki-3.12.0/run/system/OSP.dat


BIN
apache-jena-fuseki-3.12.0/run/system/OSP.idn


BIN
apache-jena-fuseki-3.12.0/run/system/OSPG.dat


BIN
apache-jena-fuseki-3.12.0/run/system/OSPG.idn


BIN
apache-jena-fuseki-3.12.0/run/system/POS.dat


BIN
apache-jena-fuseki-3.12.0/run/system/POS.idn


BIN
apache-jena-fuseki-3.12.0/run/system/POSG.dat


BIN
apache-jena-fuseki-3.12.0/run/system/POSG.idn


BIN
apache-jena-fuseki-3.12.0/run/system/SPO.dat


BIN
apache-jena-fuseki-3.12.0/run/system/SPO.idn


BIN
apache-jena-fuseki-3.12.0/run/system/SPOG.dat


BIN
apache-jena-fuseki-3.12.0/run/system/SPOG.idn


+ 0 - 0
apache-jena-fuseki-3.12.0/run/system/journal.jrnl


BIN
apache-jena-fuseki-3.12.0/run/system/node2id.dat


BIN
apache-jena-fuseki-3.12.0/run/system/node2id.idn


+ 0 - 0
apache-jena-fuseki-3.12.0/run/system/nodes.dat


BIN
apache-jena-fuseki-3.12.0/run/system/prefix2id.dat


BIN
apache-jena-fuseki-3.12.0/run/system/prefix2id.idn


BIN
apache-jena-fuseki-3.12.0/run/system/prefixIdx.dat


BIN
apache-jena-fuseki-3.12.0/run/system/prefixIdx.idn


+ 0 - 0
apache-jena-fuseki-3.12.0/run/system/prefixes.dat


+ 32 - 0
apache-jena-fuseki-3.12.0/run/system/tdb.cfg

@@ -0,0 +1,32 @@
+{ 
+  "tdb.file_mode" : "direct" ,
+  "tdb.block_size" : 1024 ,
+  "tdb.block_read_cache_size" : 50 ,
+  "tdb.block_write_cache_size" : 20 ,
+  "tdb.node2nodeid_cache_size" : 500 ,
+  "tdb.nodeid2node_cache_size" : 500 ,
+  "tdb.node_miss_cache_size" : 100 ,
+  "tdb.index_node2id" : "node2id" ,
+  "tdb.index_id2node" : "nodes" ,
+  "tdb.triple_index_primary" : "SPO" ,
+  "tdb.triple_indexes" : [ 
+      "SPO" ,
+      "POS" ,
+      "OSP"
+    ] ,
+  "tdb.quad_index_primary" : "GSPO" ,
+  "tdb.quad_indexes" : [ 
+      "GSPO" ,
+      "GPOS" ,
+      "GOSP" ,
+      "POSG" ,
+      "OSPG" ,
+      "SPOG"
+    ] ,
+  "tdb.prefix_index_primary" : "GPU" ,
+  "tdb.prefix_indexes" : [ "GPU" ] ,
+  "tdb.file_prefix_index" : "prefixIdx" ,
+  "tdb.file_prefix_nodeid" : "prefix2id" ,
+  "tdb.file_prefix_id2node" : "prefixes"
+}
+

+ 27 - 0
apache-jena-fuseki-3.12.0/run/templates/config-mem

@@ -0,0 +1,27 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+## ---------------------------------------------------------------
+## Updatable in-memory dataset.
+
+<#service1> rdf:type fuseki:Service ;
+    # URI of the dataset -- http://host:port/{NAME}
+    fuseki:name                        "{NAME}" ;
+    fuseki:serviceQuery                "sparql" ;
+    fuseki:serviceQuery                "query" ;
+    fuseki:serviceUpdate               "update" ;
+    fuseki:serviceUpload               "upload" ;
+    fuseki:serviceReadWriteGraphStore  "data" ;     
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset                     <#dataset> ;
+    .
+
+# Transactional, in-memory dataset. Initially empty.
+<#dataset> rdf:type ja:DatasetTxnMem .

+ 23 - 0
apache-jena-fuseki-3.12.0/run/templates/config-service

@@ -0,0 +1,23 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+## ---------------------------------------------------------------
+## Read-only in-memory dataset - used as a default, dummy datasets
+
+<#service1> rdf:type fuseki:Service ;
+    fuseki:name                        "" ;
+    fuseki:serviceQuery                "sparql" ;
+    fuseki:serviceQuery                "query" ;
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset                     <#dataset> ;
+    .
+
+## In-memory, empty.
+<#dataset> rdf:type ja:RDFDataset .

+ 31 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb

@@ -0,0 +1,31 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+## ---------------------------------------------------------------
+## Updatable TDB dataset with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;
+    tdb:location "{FUSEKI_BASE}/databases/{NAME}" ;
+    ##ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "3000" ] ;
+    ##tdb:unionDefaultGraph true ;
+    .

+ 30 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb-dir

@@ -0,0 +1,30 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+## ---------------------------------------------------------------
+## Updatable TDB dataset with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;
+    tdb:location "{DIR}" ;
+    ##tdb:unionDefaultGraph true ;
+    .

+ 30 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb-mem

@@ -0,0 +1,30 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+@prefix :        <#> .
+@prefix fuseki:  <http://jena.apache.org/fuseki#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+
+## ---------------------------------------------------------------
+## Updatable TDB dataset im-memory with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;
+    tdb:location "--mem--" ;
+    ## tdb:unionDefaultGraph true ;
+    .

+ 31 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb2

@@ -0,0 +1,31 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+PREFIX :        <#>
+PREFIX fuseki:  <http://jena.apache.org/fuseki#>
+PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX tdb2:    <http://jena.apache.org/2016/tdb#>
+PREFIX ja:      <http://jena.hpl.hp.com/2005/11/Assembler#>
+
+## ---------------------------------------------------------------
+## Updatable TDB dataset with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB2 {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb2:DatasetTDB2 ;
+    tdb2:location "{FUSEKI_BASE}/databases/{NAME}" ;
+    ##ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "3000" ] ;
+    ##tdb2:unionDefaultGraph true ;
+    .

+ 30 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb2-dir

@@ -0,0 +1,30 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+PREFIX :        <#>
+PREFIX fuseki:  <http://jena.apache.org/fuseki#>
+PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX tdb2:    <http://jena.apache.org/2016/tdb#>
+PREFIX ja:      <http://jena.hpl.hp.com/2005/11/Assembler#>
+
+## ---------------------------------------------------------------
+## Updatable TDB2 dataset with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB2 {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb2:DatasetTDB2 ;
+    tdb2:location "{DIR}" ;
+    ##tdb2:unionDefaultGraph true ;
+    .

+ 30 - 0
apache-jena-fuseki-3.12.0/run/templates/config-tdb2-mem

@@ -0,0 +1,30 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+PREFIX :        <#>
+PREFIX fuseki:  <http://jena.apache.org/fuseki#>
+PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX tdb2:    <http://jena.apache.org/2016/tdb#>
+PREFIX ja:      <http://jena.hpl.hp.com/2005/11/Assembler#>
+
+## ---------------------------------------------------------------
+## Updatable TDB2 dataset im-memory with all services enabled.
+
+<#service_tdb_all> rdf:type fuseki:Service ;
+    rdfs:label                      "TDB2 {NAME}" ;
+    fuseki:name                     "{NAME}" ;
+    fuseki:serviceQuery             "query" ;
+    fuseki:serviceQuery             "sparql" ;
+    fuseki:serviceUpdate            "update" ;
+    fuseki:serviceUpload            "upload" ;
+    fuseki:serviceReadWriteGraphStore      "data" ;
+    # A separate read-only graph store endpoint:
+    fuseki:serviceReadGraphStore       "get" ;
+    fuseki:dataset           <#tdb_dataset_readwrite> ;
+    
+    .
+
+<#tdb_dataset_readwrite> rdf:type      tdb2:DatasetTDB2 ;
+    tdb2:location "--mem--" ;
+    ## tdb2:unionDefaultGraph true ;
+    .

+ 332 - 0
apache-jena-fuseki-3.12.0/webapp/WEB-INF/web.xml

@@ -0,0 +1,332 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+	 version="3.0">
+
+  <display-name>Apache Jena Fuseki Server</display-name>
+
+  <listener>
+    <!-- Basic server initialiation, including logging -->
+    <listener-class>org.apache.jena.fuseki.webapp.FusekiServerEnvironmentInit</listener-class>
+  </listener>
+
+  <!-- Apache Shiro setup -->
+  <listener>
+    <!-- This replaces org.apache.shiro.web.env.EnvironmentLoaderListener
+         Support multiple locations and looks in Fuseki-relevant places.
+     -->
+    <listener-class>org.apache.jena.fuseki.webapp.ShiroEnvironmentLoader</listener-class>
+  </listener>
+
+  <!-- Apache Jena Fuseki setup -->
+
+  <listener>
+    <listener-class>org.apache.jena.fuseki.webapp.FusekiServerListener</listener-class>
+  </listener>
+
+  <!-- CORS -->
+  <filter>
+    <filter-name>cross-origin</filter-name>
+    <!-- Ported and standalone version of org.eclipse.jetty.servlets.CrossOriginFilter -->
+    <filter-class>org.apache.jena.fuseki.servlets.CrossOriginFilter</filter-class>
+    <!-- Defaults may be fine --> 
+    <init-param>
+      <param-name>allowedOrigins</param-name>
+      <param-value>*</param-value>
+    </init-param>
+    <init-param>
+      <param-name>allowedMethods</param-name>
+      <param-value>GET,POST,DELETE,PUT,HEAD,OPTIONS,PATCH</param-value>
+    </init-param>
+    <init-param>
+      <param-name>allowedHeaders</param-name>
+      <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified, Authorization</param-value>
+    </init-param>
+    <init-param>
+      <param-name>exposedHeaders</param-name>
+      <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
+    </init-param>
+  </filter>
+  
+  <filter-mapping>
+    <filter-name>cross-origin</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+
+  <!-- Before FusekiFilter -->
+  <filter>
+    <filter-name>ShiroFilter</filter-name>
+    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>ShiroFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+    <dispatcher>INCLUDE</dispatcher>
+    <dispatcher>ERROR</dispatcher>
+  </filter-mapping>
+
+  <context-param>
+    <param-name>shiroConfigLocations</param-name>
+    <!-- Try a path name in: FUSEKI_BASE, FUSEKI_HOME, war resource
+	 If a "file:" then look there and there only.
+    -->
+    <param-value>shiro.ini</param-value>
+  </context-param>
+  
+  <!-- Fuseki datatset serviced calls -->
+  <filter>
+    <filter-name>Fuseki</filter-name>
+    <filter-class>org.apache.jena.fuseki.servlets.FusekiFilter</filter-class>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>Fuseki</filter-name>
+    <url-pattern>/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+    <dispatcher>INCLUDE</dispatcher>
+    <dispatcher>ERROR</dispatcher>
+  </filter-mapping>
+
+  <!-- Validators -->
+
+  <servlet>
+    <servlet-name>QueryValidator</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.validation.QueryValidator</servlet-class>
+  </servlet>
+
+  <servlet>
+    <servlet-name>UpdateValidator</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.validation.UpdateValidator</servlet-class>
+  </servlet>
+
+  <servlet>
+    <servlet-name>DataValidator</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.validation.DataValidator</servlet-class>
+  </servlet>
+
+  <servlet>
+    <servlet-name>IRIValidator</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.validation.IRIValidator</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>QueryValidator</servlet-name>
+    <url-pattern>/validate/query</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>UpdateValidator</servlet-name>
+    <url-pattern>/validate/update</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>IRIValidator</servlet-name>
+    <url-pattern>/validate/iri</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>DataValidator</servlet-name>
+    <url-pattern>/validate/data</url-pattern>
+  </servlet-mapping>
+
+  <!-- Server controls-->
+  
+  <servlet>
+    <servlet-name>PingServlet</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.ctl.ActionPing</servlet-class>
+  </servlet>
+  
+  <servlet-mapping>
+    <servlet-name>PingServlet</servlet-name>
+    <url-pattern>/$/ping</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>ActionStats</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.ctl.ActionStats</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ActionStats</servlet-name>
+    <url-pattern>/$/stats/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>ActionMetrics</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.ctl.ActionMetrics</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ActionMetrics</servlet-name>
+    <url-pattern>/$/metrics</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>ActionTasks</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.ctl.ActionTasks</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ActionTasks</servlet-name>
+    <url-pattern>/$/tasks/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>ActionBackup</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.mgt.ActionBackup</servlet-class>
+  </servlet>
+
+  <servlet>
+    <servlet-name>BackupListServlet</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.mgt.ActionBackupList</servlet-class>
+  </servlet>
+
+  <!-- An action that only creates a background task that sleeps. -->
+  <servlet>
+    <servlet-name>ActionSleep</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.ctl.ActionSleep</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ActionSleep</servlet-name>
+    <url-pattern>/$/sleep/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ActionBackup</servlet-name>
+    <url-pattern>/$/backup/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ActionBackup</servlet-name>
+    <url-pattern>/$/backups/*</url-pattern>         <!-- Alt spelling -->
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>BackupListServlet</servlet-name>
+    <url-pattern>/$/backups-list</url-pattern>
+  </servlet-mapping>
+
+  <!-- Admin controls-->
+
+  <servlet>
+    <servlet-name>ServerStatusServlet</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.mgt.ActionServerStatus</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ServerStatusServlet</servlet-name>
+    <url-pattern>/$/server</url-pattern>
+  </servlet-mapping>
+
+  <!-- Alternative name mentioned in default shiro.ini -->
+  <servlet-mapping>
+    <servlet-name>ServerStatusServlet</servlet-name>
+    <url-pattern>/$/status</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>ActionDatasets</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.mgt.ActionDatasets</servlet-class>
+  </servlet>
+  
+  <servlet>
+    <servlet-name>ActionLogs</servlet-name>
+    <servlet-class>org.apache.jena.fuseki.mgt.ActionLogs</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ActionDatasets</servlet-name>
+    <url-pattern>/$/datasets/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ActionLogs</servlet-name>
+    <url-pattern>/$/logs</url-pattern>
+  </servlet-mapping>
+
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+  </welcome-file-list>
+
+  <!-- For serving static files -->
+
+  <mime-mapping>
+    <extension>rdf</extension>
+    <mime-type>application/rdf+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ttl</extension>
+    <mime-type>text/turtle;charset=utf-8</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>nt</extension>
+    <mime-type>application/n-triples</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>nq</extension>
+    <mime-type>application/n-quads</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>trig</extension>
+    <mime-type>application/trig</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jsonld</extension>
+    <mime-type>application/ld+json</mime-type>
+  </mime-mapping>
+
+  <mime-mapping>
+    <extension>tr</extension>
+    <mime-type>application/rdf+thrift</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>trdf</extension>
+    <mime-type>application/rdf+thrift</mime-type>
+  </mime-mapping>
+  
+  <mime-mapping>
+    <extension>rq</extension>
+    <mime-type>application/sparql-query</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ru</extension>
+    <mime-type>application/sparql-update</mime-type>
+  </mime-mapping>
+
+  <mime-mapping>
+    <extension>srx</extension>
+    <mime-type>application/sparql-results+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>srj</extension>
+    <mime-type>application/sparql-results+json</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>srt</extension>
+    <mime-type>application/sparql-results+thrift</mime-type>
+  </mime-mapping>
+
+</web-app>

+ 73 - 0
apache-jena-fuseki-3.12.0/webapp/admin-logs.html

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Apache Jena Fuseki</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <link href="../css/bootstrap.min.css" rel="stylesheet" media="screen">
+    <link href="../css/font-awesome.min.css" rel="stylesheet" media="screen">
+    <link href="../css/codemirror.css" rel="stylesheet" media="screen">
+    <link href="../css/qonsole.css" rel="stylesheet" media="screen">
+    <link href="../css/jquery.dataTables.css" rel="stylesheet" media="screen">
+    <link href="../css/fui.css" rel="stylesheet" media="screen">
+
+    <!--[if lt IE 9]>
+      <script src="../js/lib/html5shiv.js"></script>
+      <script src="../js/lib/respond.min.js"></script>
+    <![endif]-->
+  </head>
+  <body>
+    <nav class="navbar navbar-default" role="navigation">
+      <div class="container">
+        <div class="row">
+          <!-- Brand and toggle get grouped for better mobile display -->
+          <div class="navbar-header">
+            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
+              <span class="sr-only">Toggle navigation</span>
+              <span class="icon-bar"></span>
+              <span class="icon-bar"></span>
+              <span class="icon-bar"></span>
+            </button>
+            <a class="navbar-brand" href="index.html">
+              <img src="images/jena-logo-notext-small.png" alt="Apache Jena logo" title="Apache Jena" />
+              <div>Apache<br />Jena<br /><strong>Fuseki</strong></div>
+            </a>
+          </div>
+
+          <!-- Collect the nav links, forms, and other content for toggling -->
+          <div class="collapse navbar-collapse navbar-ex1-collapse">
+            <ul class="nav navbar-nav">
+              <li class=""><a href="index.html"><i class="fa fa-home"></i></a></li>
+              <li class=""><a href="query.html"><i class="fa fa-question-circle"></i> query</a></li>
+              <li class=""><a href="validate.html"><i class="fa fa-check-circle"></i> validate</a></li>
+              <li class="admin"><a href="admin-data-management.html"><i class="fa fa-cogs"></i> administer</a></li>
+              <li class="admin"><a href="admin-stats.html"><i class="fa fa-dashboard"></i> stats</a></li>
+              <li class="admin active"><a href="admin-logs.html"><i class="fa fa-book"></i> logs</a></li>
+              <li class=""><a href="documentation.html"><i class="fa fa-info-circle"></i> help</a></li>
+            </ul>
+            <ul class="nav navbar-nav navbar-right">
+              <li class="status-indicator">
+                <div>Server<br />status:</div>
+              </li>
+              <li class="status-indicator">
+                <a class="" href="#admin/server-log.html" id="server-status-light" title="current server status">
+                  <span class="server-up"></span>
+                </a>
+              </li>
+            </ul>
+          </div><!-- /.navbar-collapse -->
+        </div><!-- /row -->
+      </div><!-- /container -->
+    </nav>
+
+    <div class="container">
+      <div class="row">
+        <h1>Server logs</h1>
+        <p class="text-danger">Forthcoming feature. Show some or all of the recent log file, assuming it is in the usual place.</p>
+      </div>
+    </div>
+
+    <script src="../js/lib/jquery-1.10.2.min.js"></script>
+    <script src="../js/lib/bootstrap.min.js"></script>
+  </body>
+</html>

File diff suppressed because it is too large
+ 6 - 0
apache-jena-fuseki-3.12.0/webapp/css/bootstrap-select.min.css


File diff suppressed because it is too large
+ 0 - 0
apache-jena-fuseki-3.12.0/webapp/css/bootstrap-theme.css.map


File diff suppressed because it is too large
+ 6 - 0
apache-jena-fuseki-3.12.0/webapp/css/bootstrap-theme.min.css


File diff suppressed because it is too large
+ 0 - 0
apache-jena-fuseki-3.12.0/webapp/css/bootstrap.css.map


File diff suppressed because it is too large
+ 6 - 0
apache-jena-fuseki-3.12.0/webapp/css/bootstrap.min.css


+ 301 - 0
apache-jena-fuseki-3.12.0/webapp/css/codemirror.css

@@ -0,0 +1,301 @@
+/* BASICS */
+
+.CodeMirror {
+  /* Set height, width, borders, and global font properties here */
+  font-family: monospace;
+  height: 300px;
+}
+.CodeMirror-scroll {
+  /* Set scrolling behaviour here */
+  overflow: auto;
+}
+
+/* PADDING */
+
+.CodeMirror-lines {
+  padding: 4px 0; /* Vertical padding around content */
+}
+.CodeMirror pre {
+  padding: 0 4px; /* Horizontal padding of content */
+}
+
+.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
+  background-color: white; /* The little square between H and V scrollbars */
+}
+
+/* GUTTER */
+
+.CodeMirror-gutters {
+  border-right: 1px solid #ddd;
+  background-color: #f7f7f7;
+  white-space: nowrap;
+}
+.CodeMirror-linenumbers {}
+.CodeMirror-linenumber {
+  padding: 0 3px 0 5px;
+  min-width: 20px;
+  text-align: right;
+  color: #999;
+  -moz-box-sizing: content-box;
+  box-sizing: content-box;
+}
+
+.CodeMirror-guttermarker { color: black; }
+.CodeMirror-guttermarker-subtle { color: #999; }
+
+/* CURSOR */
+
+.CodeMirror div.CodeMirror-cursor {
+  border-left: 1px solid black;
+}
+/* Shown when moving in bi-directional text */
+.CodeMirror div.CodeMirror-secondarycursor {
+  border-left: 1px solid silver;
+}
+.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
+  width: auto;
+  border: 0;
+  background: #7e7;
+}
+.cm-animate-fat-cursor {
+  width: auto;
+  border: 0;
+  -webkit-animation: blink 1.06s steps(1) infinite;
+  -moz-animation: blink 1.06s steps(1) infinite;
+  animation: blink 1.06s steps(1) infinite;
+}
+@-moz-keyframes blink {
+  0% { background: #7e7; }
+  50% { background: none; }
+  100% { background: #7e7; }
+}
+@-webkit-keyframes blink {
+  0% { background: #7e7; }
+  50% { background: none; }
+  100% { background: #7e7; }
+}
+@keyframes blink {
+  0% { background: #7e7; }
+  50% { background: none; }
+  100% { background: #7e7; }
+}
+
+/* Can style cursor different in overwrite (non-insert) mode */
+div.CodeMirror-overwrite div.CodeMirror-cursor {}
+
+.cm-tab { display: inline-block; }
+
+.CodeMirror-ruler {
+  border-left: 1px solid #ccc;
+  position: absolute;
+}
+
+/* DEFAULT THEME */
+
+.cm-s-default .cm-keyword {color: #708;}
+.cm-s-default .cm-atom {color: #219;}
+.cm-s-default .cm-number {color: #164;}
+.cm-s-default .cm-def {color: #00f;}
+.cm-s-default .cm-variable,
+.cm-s-default .cm-punctuation,
+.cm-s-default .cm-property,
+.cm-s-default .cm-operator {}
+.cm-s-default .cm-variable-2 {color: #05a;}
+.cm-s-default .cm-variable-3 {color: #085;}
+.cm-s-default .cm-comment {color: #a50;}
+.cm-s-default .cm-string {color: #a11;}
+.cm-s-default .cm-string-2 {color: #f50;}
+.cm-s-default .cm-meta {color: #555;}
+.cm-s-default .cm-qualifier {color: #555;}
+.cm-s-default .cm-builtin {color: #30a;}
+.cm-s-default .cm-bracket {color: #997;}
+.cm-s-default .cm-tag {color: #170;}
+.cm-s-default .cm-attribute {color: #00c;}
+.cm-s-default .cm-header {color: blue;}
+.cm-s-default .cm-quote {color: #090;}
+.cm-s-default .cm-hr {color: #999;}
+.cm-s-default .cm-link {color: #00c;}
+
+.cm-negative {color: #d44;}
+.cm-positive {color: #292;}
+.cm-header, .cm-strong {font-weight: bold;}
+.cm-em {font-style: italic;}
+.cm-link {text-decoration: underline;}
+
+.cm-s-default .cm-error {color: #f00;}
+.cm-invalidchar {color: #f00;}
+
+/* Default styles for common addons */
+
+div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
+div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
+.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
+.CodeMirror-activeline-background {background: #e8f2ff;}
+
+/* STOP */
+
+/* The rest of this file contains styles related to the mechanics of
+   the editor. You probably shouldn't touch them. */
+
+.CodeMirror {
+  line-height: 1;
+  position: relative;
+  overflow: hidden;
+  background: white;
+  color: black;
+}
+
+.CodeMirror-scroll {
+  /* 30px is the magic margin used to hide the element's real scrollbars */
+  /* See overflow: hidden in .CodeMirror */
+  margin-bottom: -30px; margin-right: -30px;
+  padding-bottom: 30px;
+  height: 100%;
+  outline: none; /* Prevent dragging from highlighting the element */
+  position: relative;
+  -moz-box-sizing: content-box;
+  box-sizing: content-box;
+}
+.CodeMirror-sizer {
+  position: relative;
+  border-right: 30px solid transparent;
+  -moz-box-sizing: content-box;
+  box-sizing: content-box;
+}
+
+/* The fake, visible scrollbars. Used to force redraw during scrolling
+   before actuall scrolling happens, thus preventing shaking and
+   flickering artifacts. */
+.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
+  position: absolute;
+  z-index: 6;
+  display: none;
+}
+.CodeMirror-vscrollbar {
+  right: 0; top: 0;
+  overflow-x: hidden;
+  overflow-y: scroll;
+}
+.CodeMirror-hscrollbar {
+  bottom: 0; left: 0;
+  overflow-y: hidden;
+  overflow-x: scroll;
+}
+.CodeMirror-scrollbar-filler {
+  right: 0; bottom: 0;
+}
+.CodeMirror-gutter-filler {
+  left: 0; bottom: 0;
+}
+
+.CodeMirror-gutters {
+  position: absolute; left: 0; top: 0;
+  padding-bottom: 30px;
+  z-index: 3;
+}
+.CodeMirror-gutter {
+  white-space: normal;
+  height: 100%;
+  -moz-box-sizing: content-box;
+  box-sizing: content-box;
+  padding-bottom: 30px;
+  margin-bottom: -32px;
+  display: inline-block;
+  /* Hack to make IE7 behave */
+  *zoom:1;
+  *display:inline;
+}
+.CodeMirror-gutter-elt {
+  position: absolute;
+  cursor: default;
+  z-index: 4;
+}
+
+.CodeMirror-lines {
+  cursor: text;
+}
+.CodeMirror pre {
+  /* Reset some styles that the rest of the page might have set */
+  -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
+  border-width: 0;
+  background: transparent;
+  font-family: inherit;
+  font-size: inherit;
+  margin: 0;
+  white-space: pre;
+  word-wrap: normal;
+  line-height: inherit;
+  color: inherit;
+  z-index: 2;
+  position: relative;
+  overflow: visible;
+}
+.CodeMirror-wrap pre {
+  word-wrap: break-word;
+  white-space: pre-wrap;
+  word-break: normal;
+}
+
+.CodeMirror-linebackground {
+  position: absolute;
+  left: 0; right: 0; top: 0; bottom: 0;
+  z-index: 0;
+}
+
+.CodeMirror-linewidget {
+  position: relative;
+  z-index: 2;
+  overflow: auto;
+}
+
+.CodeMirror-widget {}
+
+.CodeMirror-wrap .CodeMirror-scroll {
+  overflow-x: hidden;
+}
+
+.CodeMirror-measure {
+  position: absolute;
+  width: 100%;
+  height: 0;
+  overflow: hidden;
+  visibility: hidden;
+}
+.CodeMirror-measure pre { position: static; }
+
+.CodeMirror div.CodeMirror-cursor {
+  position: absolute;
+  border-right: none;
+  width: 0;
+}
+
+div.CodeMirror-cursors {
+  visibility: hidden;
+  position: relative;
+  z-index: 1;
+}
+.CodeMirror-focused div.CodeMirror-cursors {
+  visibility: visible;
+}
+
+.CodeMirror-selected { background: #d9d9d9; }
+.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
+.CodeMirror-crosshair { cursor: crosshair; }
+
+.cm-searching {
+  background: #ffa;
+  background: rgba(255, 255, 0, .4);
+}
+
+/* IE7 hack to prevent it from returning funny offsetTops on the spans */
+.CodeMirror span { *vertical-align: text-bottom; }
+
+/* Used to force a border model for a node */
+.cm-force-border { padding-right: .1px; }
+
+@media print {
+  /* Hide the cursor when printing */
+  .CodeMirror div.CodeMirror-cursors {
+    visibility: hidden;
+  }
+}

File diff suppressed because it is too large
+ 0 - 0
apache-jena-fuseki-3.12.0/webapp/css/codemirror.min.css


File diff suppressed because it is too large
+ 3 - 0
apache-jena-fuseki-3.12.0/webapp/css/font-awesome.min.css


+ 191 - 0
apache-jena-fuseki-3.12.0/webapp/css/fui.css

@@ -0,0 +1,191 @@
+h1 {
+  margin-top: 0;
+  font-size: 18pt;
+}
+
+h1 + p {
+  margin-bottom: 20px;
+}
+
+h2 {
+  margin-top: 0;
+  font-size: 16pt;
+}
+
+h2 + p {
+  margin-bottom: 18px;
+}
+
+h3 {
+  font-size: 13pt;
+}
+
+a#server-status-light {
+  display: inline-block;
+  margin: 0;
+  padding-left: 8px;
+  padding-top: 2px;
+}
+#server-status-light span {
+  width: 24px;
+  height: 24px;
+  border-radius: 12px;
+  display: inline-block;
+  margin-bottom: -8px;
+}
+#server-status-light span.server-up {
+  background-color: #38a800;
+  border:1px solid #4b9b23;
+
+  background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #59e811), color-stop(1, #38a800));
+  background:-moz-linear-gradient(top, #59e811 5%, #38a800 100%);
+  background:-webkit-linear-gradient(top, #59e811 5%, #38a800 100%);
+  background:-o-linear-gradient(top, #59e811 5%, #38a800 100%);
+  background:-ms-linear-gradient(top, #59e811 5%, #38a800 100%);
+  background:linear-gradient(to bottom, #59e811 5%, #38a800 100%);
+  filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#59e811', endColorstr='#38a800',GradientType=0);
+}
+
+#server-status-light span.server-down {
+  background-color: #d21e1e;
+  border:1px solid #a02323;
+
+  background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ed2424), color-stop(1, #d21e1e));
+  background:-moz-linear-gradient(top, #ed2424 5%, #d21e1e 100%);
+  background:-webkit-linear-gradient(top, #ed2424 5%, #d21e1e 100%);
+  background:-o-linear-gradient(top, #ed2424 5%, #d21e1e 100%);
+  background:-ms-linear-gradient(top, #ed2424 5%, #d21e1e 100%);
+  background:linear-gradient(to bottom, #ed2424 5%, #d21e1e 100%);
+  filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89306',GradientType=0);
+}
+
+a.navbar-brand {
+  padding-top: 0;
+  padding-bottom: 0;
+  font-size: 15px;
+  line-height: 1.0;
+}
+
+a.navbar-brand div {
+  display: inline-block;
+}
+
+a.navbar-brand img {
+  margin-top: -25px;
+}
+
+.navbar-right {
+  color: #777;
+  line-height: 1.0;
+}
+
+.navbar-item {
+  padding-top: 15px;
+  padding-right: 4px;
+}
+
+.navbar-nav > li > a > i {
+  color: #428bca;
+}
+
+.options-list {
+  margin-bottom: 5px;
+}
+
+.validation-warning {
+  display:none;
+}
+.has-error .validation-warning, .has-warning .validation-warning {
+  display:block;
+}
+
+.current-dataset {
+  margin-right: 20px;
+}
+
+.current-datasets {
+  margin-top: 20px;
+  margin-bottom: 20px;
+}
+
+.status-indicator {
+  padding-top: 10px;
+}
+
+.select-picker-label {
+  height: 30px;
+  vertical-align: middle;
+  display: inline-block;
+}
+
+.content-frame {
+  background-color: #eee;
+  border: 1px solid #aaa;
+  border-radius: 5px;
+  padding: 5px;
+}
+
+.tab-pane > div {
+  background-color: white;
+  border-radius: 3px;
+}
+
+#sparqlEndpoint {
+  min-width: 300px;
+}
+
+#fileuploadForm .progress {
+  margin-top: 0;
+  margin-bottom: 5px;
+}
+
+.tab-pane .with-dataset {
+  padding: 5px;
+}
+
+.file-description {
+  margin-top: 10px;
+}
+
+.graph-label label {
+  text-align: right;
+  padding-top: 5px;
+}
+
+.dl-horizontal dt {
+  width: 240px;
+}
+
+.dl-horizontal dd {
+  margin-left: 260px
+}
+
+dt span.heading, dd span.heading {
+  font-weight: bold;
+  background-color: #eee;
+  padding: 3px 8px;
+}
+
+dt span.heading {
+  padding-right: 2px;
+}
+dd span.heading {
+  padding-left: 2px;
+}
+dt.font-weight-normal {
+  font-weight: normal;
+}
+dd .numeric {
+  display: inline-block;
+  min-width: 4em;
+  text-align: right;
+}
+
+.bordered-box {
+  border: 1px solid #ccc;
+  border-radius: 5px;
+}
+
+.pull-right > button {
+  margin: 10px 2px 0 0;
+}

+ 220 - 0
apache-jena-fuseki-3.12.0/webapp/css/jquery.dataTables.css

@@ -0,0 +1,220 @@
+
+/*
+ * Table
+ */
+table.dataTable {
+  margin: 0 auto;
+  clear: both;
+  width: 100%;
+}
+
+table.dataTable thead th {
+  padding: 3px 18px 3px 10px;
+  border-bottom: 1px solid black;
+  font-weight: bold;
+  cursor: pointer;
+  *cursor: hand;
+}
+
+table.dataTable tfoot th {
+  padding: 3px 18px 3px 10px;
+  border-top: 1px solid black;
+  font-weight: bold;
+}
+
+table.dataTable td {
+  padding: 3px 10px;
+}
+
+table.dataTable td.center,
+table.dataTable td.dataTables_empty {
+  text-align: center;
+}
+
+table.dataTable tr.odd { background-color: #E2E4FF; }
+table.dataTable tr.even { background-color: white; }
+
+table.dataTable tr.odd td.sorting_1 { background-color: #D3D6FF; }
+table.dataTable tr.odd td.sorting_2 { background-color: #DADCFF; }
+table.dataTable tr.odd td.sorting_3 { background-color: #E0E2FF; }
+table.dataTable tr.even td.sorting_1 { background-color: #EAEBFF; }
+table.dataTable tr.even td.sorting_2 { background-color: #F2F3FF; }
+table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; }
+
+
+/*
+ * Table wrapper
+ */
+.dataTables_wrapper {
+  position: relative;
+  clear: both;
+  *zoom: 1;
+}
+
+
+/*
+ * Page length menu
+ */
+.dataTables_length {
+  float: left;
+}
+
+
+/*
+ * Filter
+ */
+.dataTables_filter {
+  float: right;
+  text-align: right;
+}
+
+
+/*
+ * Table information
+ */
+.dataTables_info {
+  clear: both;
+  float: left;
+}
+
+
+/*
+ * Pagination
+ */
+.dataTables_paginate {
+  float: right;
+  text-align: right;
+}
+
+/* Two button pagination - previous / next */
+.paginate_disabled_previous,
+.paginate_enabled_previous,
+.paginate_disabled_next,
+.paginate_enabled_next {
+  height: 19px;
+  float: left;
+  cursor: pointer;
+  *cursor: hand;
+  color: #111 !important;
+}
+.paginate_disabled_previous:hover,
+.paginate_enabled_previous:hover,
+.paginate_disabled_next:hover,
+.paginate_enabled_next:hover {
+  text-decoration: none !important;
+}
+.paginate_disabled_previous:active,
+.paginate_enabled_previous:active,
+.paginate_disabled_next:active,
+.paginate_enabled_next:active {
+  outline: none;
+}
+
+.paginate_disabled_previous,
+.paginate_disabled_next {
+  color: #666 !important;
+}
+.paginate_disabled_previous,
+.paginate_enabled_previous {
+  padding-left: 23px;
+}
+.paginate_disabled_next,
+.paginate_enabled_next {
+  padding-right: 23px;
+  margin-left: 10px;
+}
+
+.paginate_enabled_previous { background: url('../images/back_enabled.png') no-repeat top left; }
+.paginate_enabled_previous:hover { background: url('../images/back_enabled_hover.png') no-repeat top left; }
+.paginate_disabled_previous { background: url('../images/back_disabled.png') no-repeat top left; }
+
+.paginate_enabled_next { background: url('../images/forward_enabled.png') no-repeat top right; }
+.paginate_enabled_next:hover { background: url('../images/forward_enabled_hover.png') no-repeat top right; }
+.paginate_disabled_next { background: url('../images/forward_disabled.png') no-repeat top right; }
+
+/* Full number pagination */
+.paging_full_numbers {
+  height: 22px;
+  line-height: 22px;
+}
+.paging_full_numbers a:active {
+  outline: none
+}
+.paging_full_numbers a:hover {
+  text-decoration: none;
+}
+
+.paging_full_numbers a.paginate_button,
+.paging_full_numbers a.paginate_active {
+  border: 1px solid #aaa;
+  -webkit-border-radius: 5px;
+  -moz-border-radius: 5px;
+  border-radius: 5px;
+  padding: 2px 5px;
+  margin: 0 3px;
+  cursor: pointer;
+  *cursor: hand;
+  color: #333 !important;
+}
+
+.paging_full_numbers a.paginate_button {
+  background-color: #ddd;
+}
+
+.paging_full_numbers a.paginate_button:hover {
+  background-color: #ccc;
+  text-decoration: none !important;
+}
+
+.paging_full_numbers a.paginate_active {
+  background-color: #99B3FF;
+}
+
+
+/*
+ * Processing indicator
+ */
+.dataTables_processing {
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  width: 250px;
+  height: 30px;
+  margin-left: -125px;
+  margin-top: -15px;
+  padding: 14px 0 2px 0;
+  border: 1px solid #ddd;
+  text-align: center;
+  color: #999;
+  font-size: 14px;
+  background-color: white;
+}
+
+
+/*
+ * Sorting
+ */
+.sorting { background: url('../images/sort_both.png') no-repeat center right; }
+.sorting_asc { background: url('../images/sort_asc.png') no-repeat center right; }
+.sorting_desc { background: url('../images/sort_desc.png') no-repeat center right; }
+
+.sorting_asc_disabled { background: url('../images/sort_asc_disabled.png') no-repeat center right; }
+.sorting_desc_disabled { background: url('../images/sort_desc_disabled.png') no-repeat center right; }
+
+table.dataTable thead th:active,
+table.dataTable thead td:active {
+  outline: none;
+}
+
+
+/*
+ * Scrolling
+ */
+.dataTables_scroll {
+  clear: both;
+}
+
+.dataTables_scrollBody {
+  *margin-top: -1px;
+  -webkit-overflow-scrolling: touch;
+}

+ 22 - 0
apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-noscript.css

@@ -0,0 +1,22 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload Plugin NoScript CSS 1.2.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileinput-button input {
+  position: static;
+  opacity: 1;
+  filter: none;
+  font-size: inherit;
+  direction: inherit;
+}
+.fileinput-button span {
+  display: none;
+}

+ 17 - 0
apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-ui-noscript.css

@@ -0,0 +1,17 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload UI Plugin NoScript CSS 8.8.5
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2012, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileinput-button i,
+.fileupload-buttonbar .delete,
+.fileupload-buttonbar .toggle {
+  display: none;
+}

+ 57 - 0
apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload-ui.css

@@ -0,0 +1,57 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload UI Plugin CSS 9.0.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileupload-buttonbar .btn,
+.fileupload-buttonbar .toggle {
+  margin-bottom: 5px;
+}
+.progress-animated .progress-bar,
+.progress-animated .bar {
+  background: url("../img/progressbar.gif") !important;
+  filter: none;
+}
+.fileupload-process {
+  float: right;
+  display: none;
+}
+.fileupload-processing .fileupload-process,
+.files .processing .preview {
+  display: block;
+  width: 32px;
+  height: 32px;
+  background: url("../img/loading.gif") center no-repeat;
+  background-size: contain;
+}
+.files audio,
+.files video {
+  max-width: 300px;
+}
+
+@media (max-width: 767px) {
+  .fileupload-buttonbar .toggle,
+  .files .toggle,
+  .files .btn span {
+    display: none;
+  }
+  .files .name {
+    width: 80px;
+    word-wrap: break-word;
+  }
+  .files audio,
+  .files video {
+    max-width: 80px;
+  }
+  .files img,
+  .files canvas {
+    max-width: 100%;
+  }
+}

+ 36 - 0
apache-jena-fuseki-3.12.0/webapp/css/jquery.fileupload.css

@@ -0,0 +1,36 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload Plugin CSS 1.3.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileinput-button {
+  position: relative;
+  overflow: hidden;
+}
+.fileinput-button input {
+  position: absolute;
+  top: 0;
+  right: 0;
+  margin: 0;
+  opacity: 0;
+  -ms-filter: 'alpha(opacity=0)';
+  font-size: 200px;
+  direction: ltr;
+  cursor: pointer;
+}
+
+/* Fixes for IE < 8 */
+@media screen\9 {
+  .fileinput-button input {
+    filter: alpha(opacity=0);
+    font-size: 100%;
+    height: 100%;
+  }
+}

Some files were not shown because too many files changed in this diff