Package org.exist.source

Examples of org.exist.source.URLSource


                    if( queryUri.startsWith( XmldbURI.XMLDB_URI_PREFIX ) ) {
                        final Resource resource = base.getResource( queryUri );
                        source = new BinarySource( (byte[])resource.getContent(), true );
                    } else {
                        source = new URLSource( new URL( queryUri ) );
                    }

                } else if( queryFile != null ) {
                    log( "XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG );
                    source = new FileSource( queryFile, "UTF-8", true );
View Full Code Here


    private void executeXProc(final DBBroker broker, final DocumentImpl resource,
            final HttpServletRequest request, final HttpServletResponse response,
            final Properties outputProperties, final String servletPath, final String pathInfo)
            throws XPathException, BadRequestException, PermissionDeniedException {

        final URLSource source = new URLSource(this.getClass().getResource("run-xproc.xq"));
        final XQuery xquery = broker.getXQueryService();
        final XQueryPool pool = xquery.getXQueryPool();
        XQueryContext context;
        CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source);
        if (compiled == null) {
            context = xquery.newContext(AccessContext.REST);
        } else {
            context = compiled.getContext();
        }

        context.declareVariable("pipeline", resource.getURI().toString());
       
        final String stdin = request.getParameter("stdin");
        context.declareVariable("stdin", stdin == null ? "" : stdin);

        final String debug = request.getParameter("debug");
        context.declareVariable("debug", debug == null ? "0" : "1");

        final String bindings = request.getParameter("bindings");
        context.declareVariable("bindings", bindings == null ? "<bindings/>" : bindings);

        final String autobind = request.getParameter("autobind");
        context.declareVariable("autobind", autobind == null ? "0" : "1");

        final String options = request.getParameter("options");
        context.declareVariable("options", options == null ? "<options/>" : options);

        // TODO: don't hardcode this?
        context.setModuleLoadPath(
                XmldbURI.EMBEDDED_SERVER_URI.append(
                resource.getCollection().getURI()).toString());

        context.setStaticallyKnownDocuments(
                new XmldbURI[]{resource.getCollection().getURI()});

        final HttpRequestWrapper reqw = declareVariables(context, null, request, response);
        reqw.setServletPath(servletPath);
        reqw.setPathInfo(pathInfo);
        if (compiled == null) {
            try {
                compiled = xquery.compile(context, source);
            } catch (final IOException e) {
                throw new BadRequestException("Failed to read query from "
                        + source.getURL(), e);
            }
        }

        try {
            final Sequence result = xquery.execute(compiled, null, outputProperties);
View Full Code Here

  URLSource entryByIdSource;
  URLSource getFeedSource;

  /** Creates a new instance of AtomProtocol */
  public AtomFeeds() {
    entryByIdSource = new URLSource(this.getClass().getResource(
        "entry-by-id.xq"));
    getFeedSource = new URLSource(this.getClass()
        .getResource("get-feed.xq"));
  }
View Full Code Here

    public URL getQuerySource() {
      return querySource.getURL();
    }

    public void setQuerySource(URL source) {
      this.querySource = source == null ? null : new URLSource(source);
    }
View Full Code Here

TOP

Related Classes of org.exist.source.URLSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.