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 Open Source Native XML Database
* Copyright (C) 2001-2019 The eXist Project
* http://exist-db.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.exist.xmldb;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import javax.xml.transform.OutputKeys;
import com.evolvedbinary.j8fu.function.FunctionE;
import com.evolvedbinary.j8fu.lazy.LazyVal;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.exist.storage.serializers.EXistOutputKeys;
import org.exist.util.Leasable;
import org.exist.util.io.TemporaryFileManager;
import org.exist.util.io.VirtualTempPath;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
public class RemoteResourceSet implements ResourceSet, AutoCloseable {
private final Leasable leasableXmlRpcClient;
private final XmlRpcClient xmlRpcClient;
private final RemoteCollection collection;
private int handle = -1;
private int hash = -1;
private final List resources;
private final Properties outputProperties;
private boolean closed;
private LazyVal inMemoryBufferSize;
private static Logger LOG = LogManager.getLogger(RemoteResourceSet.class.getName());
public RemoteResourceSet(final Leasable leasableXmlRpcClient, final XmlRpcClient xmlRpcClient, final RemoteCollection col, final Properties properties, final Object[] resources, final int handle, final int hash) {
this.leasableXmlRpcClient = leasableXmlRpcClient;
this.xmlRpcClient = xmlRpcClient;
this.handle = handle;
this.hash = hash;
this.resources = new ArrayList(Arrays.asList(resources));
this.collection = col;
this.outputProperties = properties;
}
private final int getInMemorySize(Properties properties) {
if (inMemoryBufferSize == null) {
inMemoryBufferSize = new LazyVal<>(() -> Integer.parseInt(properties.getProperty("in-memory-buffer-size", Integer.toString(VirtualTempPath.DEFAULT_IN_MEMORY_SIZE))));
}
return inMemoryBufferSize.get().intValue();
}
@Override
public void addResource(final Resource resource) {
resources.add(resource);
}
@Override
public void addAll(final ResourceSet resourceSet) throws XMLDBException {
for (long i = 0; i < resourceSet.getSize(); i++) {
addResource(resourceSet.getResource(i));
}
}
@Override
public void clear() throws XMLDBException {
if (handle < 0) {
return;
}
final List