Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* [email protected]
* http://www.exist-db.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.exist.xmldb;
import java.io.IOException;
import java.io.Writer;
import java.util.*;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.exist.source.Source;
import org.exist.storage.serializers.EXistOutputKeys;
import org.exist.util.Leasable;
import org.exist.xmlrpc.RpcAPI;
import org.exist.xquery.XPathException;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.CompiledExpression;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;
import javax.xml.XMLConstants;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RemoteXPathQueryService extends AbstractRemote implements EXistXPathQueryService, EXistXQueryService {
private final Leasable leasableXmlRpcClient;
private final Map namespaceMappings = new HashMap<>();
private final Map variableDecls = new HashMap<>();
private final Properties outputProperties;
private String moduleLoadPath = null;
private boolean protectedMode = false;
/**
* Creates a new RemoteXPathQueryService instance.
*
* @param leasableXmlRpcClient the XML-RPC client lease
* @param collection a RemoteCollection value
*/
public RemoteXPathQueryService(final Leasable leasableXmlRpcClient, final RemoteCollection collection) {
super(collection);
this.leasableXmlRpcClient = leasableXmlRpcClient;
this.outputProperties = collection.getProperties();
}
@Override
public String getName() throws XMLDBException {
return "XPathQueryService";
}
@Override
public String getVersion() throws XMLDBException {
return "1.0";
}
@Override
public ResourceSet query(final String query) throws XMLDBException {
return query(query, null);
}
@Override
public ResourceSet query(final String query, final String sortExpr)
throws XMLDBException {
final Map optParams = new HashMap<>();
if (sortExpr != null) {
optParams.put(RpcAPI.SORT_EXPR, sortExpr);
}
if (namespaceMappings.size() > 0) {
optParams.put(RpcAPI.NAMESPACES, namespaceMappings);
}
if (variableDecls.size() > 0) {
optParams.put(RpcAPI.VARIABLES, variableDecls);
}
optParams.put(RpcAPI.BASE_URI, outputProperties.getProperty(RpcAPI.BASE_URI, collection.getPath()));
if (moduleLoadPath != null) {
optParams.put(RpcAPI.MODULE_LOAD_PATH, moduleLoadPath);
}
if (protectedMode) {
optParams.put(RpcAPI.PROTECTED_MODE, collection.getPath());
}
final List