Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public class UtilModule extends AbstractInternalModule {
new FunctionDef(Base64Functions.signatures[3], Base64Functions.class),
new FunctionDef(BaseConversionFunctions.FNS_INT_TO_OCTAL, BaseConversionFunctions.class),
new FunctionDef(BaseConversionFunctions.FNS_OCTAL_TO_INT, BaseConversionFunctions.class),
new FunctionDef(LineNumber.signature, LineNumber.class)
new FunctionDef(LineNumber.signature, LineNumber.class),
new FunctionDef(FileSync.signature, FileSync.class)
};

static {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!--

eXist-db Open Source Native XML Database
Copyright (C) 2001 The eXist-db Authors

info@exist-db.org
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

-->
<!--
Merge repo.xml modified by user with original file. This is necessary because we have to
remove sensitive information during upload (default password) and need to restore it
when the package is synchronized back to disk.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:repo="http://exist-db.org/xquery/repo">

<!-- Set to the original repo.xml which should be merged with the input document -->
<xsl:param name="original"/>

<xsl:template match="repo:permissions">
<permissions xmlns="http://exist-db.org/xquery/repo">
<!-- If a (new) password has been specified in the input doc, use it.
Preserve the original password otherwise.
-->
<xsl:attribute name="password">
<xsl:choose>
<xsl:when test="@password">
<xsl:value-of select="@password"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$original//repo:permissions/@password"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:copy-of select="@*[local-name(.) != 'password']"/>
</permissions>
</xsl:template>

<xsl:template match="repo:deployed"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
1 change: 1 addition & 0 deletions exist-distribution/src/main/config/conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@
<!-- module uri="http://exist-db.org/xquery/exi" class="org.exist.xquery.modules.exi.ExiModule"/ -->
<module uri="http://exist-db.org/xquery/repo" class="org.exist.xquery.modules.expathrepo.ExpathPackageModule"/>
<module uri="http://exist-db.org/xquery/file" class="org.exist.xquery.modules.file.FileModule"/>
<module uri="http://expath.org/ns/file" class="org.expath.exist.file.ExpathFileModule"/>
<module uri="http://exist-db.org/xquery/image" class="org.exist.xquery.modules.image.ImageModule"/>
<module uri="http://exist-db.org/xquery/jndi" class="org.exist.xquery.modules.jndi.JNDIModule"/>
<module uri="http://exist-db.org/xquery/mail" class="org.exist.xquery.modules.mail.MailModule"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class ZipFileFunctions extends BasicFunction {
private static final Logger logger = LogManager.getLogger(ZipFileFunctions.class);

private final static FunctionParameterSequenceType HREF_PARAM = new FunctionParameterSequenceType("href", Type.ANY_URI, Cardinality.EXACTLY_ONE, "The URI for locating the Zip file");
private final static FunctionParameterSequenceType ENTRY_PARAM = new FunctionParameterSequenceType("entry", Type.ELEMENT, Cardinality.EXACTLY_ONE, "A zip:entry element describing the contents of the file");

private final static String FILE_ENTRIES = "entries";
private final static String ZIP_FILE = "zip-file";
private final static String UPDATE_ENTRIES = "update";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* info@exist-db.org
* 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.expath.exist.file;

import org.exist.dom.QName;
import org.exist.xquery.ErrorCodes.ErrorCode;

/**
* Error codes defined by the EXPath File Module 4.0.
*
* @see <a href="https://qt4cg.org/specifications/expath-file-40/Overview.html">EXPath File Module 4.0</a>
*/
public class ExpathFileErrorCode {

public static final ErrorCode NOT_FOUND = new ErrorCode(
new QName("not-found", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path does not exist.");

public static final ErrorCode INVALID_PATH = new ErrorCode(
new QName("invalid-path", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path is invalid.");

public static final ErrorCode EXISTS = new ErrorCode(
new QName("exists", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path already exists.");

public static final ErrorCode NO_DIR = new ErrorCode(
new QName("no-dir", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path does not point to a directory.");

public static final ErrorCode IS_DIR = new ErrorCode(
new QName("is-dir", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path points to a directory.");

public static final ErrorCode IS_RELATIVE = new ErrorCode(
new QName("is-relative", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified path is relative.");

public static final ErrorCode UNKNOWN_ENCODING = new ErrorCode(
new QName("unknown-encoding", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified encoding is not supported.");

public static final ErrorCode OUT_OF_RANGE = new ErrorCode(
new QName("out-of-range", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"The specified offset or length is out of range.");

public static final ErrorCode IO_ERROR = new ErrorCode(
new QName("io-error", ExpathFileModule.NAMESPACE_URI, ExpathFileModule.PREFIX),
"A generic file system error occurred.");

private ExpathFileErrorCode() {
// no instances
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* info@exist-db.org
* 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.expath.exist.file;

import java.util.List;
import java.util.Map;

import org.exist.xquery.AbstractInternalModule;
import org.exist.xquery.FunctionDef;

/**
* EXPath File Module 4.0 implementation for eXist-db.
*
* @see <a href="https://qt4cg.org/specifications/expath-file-40/Overview.html">EXPath File Module 4.0</a>
*/
public class ExpathFileModule extends AbstractInternalModule {

public static final String NAMESPACE_URI = "http://expath.org/ns/file";
public static final String PREFIX = "exfile";
public static final String INCLUSION_DATE = "2025-05-01";
public static final String RELEASED_IN_VERSION = "7.0.0";

private static final FunctionDef[] functions = {
// FileProperties: exists, is-dir, is-file, is-absolute, last-modified, size(1), size(2)
new FunctionDef(FileProperties.signatures[0], FileProperties.class),
new FunctionDef(FileProperties.signatures[1], FileProperties.class),
new FunctionDef(FileProperties.signatures[2], FileProperties.class),
new FunctionDef(FileProperties.signatures[3], FileProperties.class),
new FunctionDef(FileProperties.signatures[4], FileProperties.class),
new FunctionDef(FileProperties.signatures[5], FileProperties.class),
new FunctionDef(FileProperties.signatures[6], FileProperties.class),

// FileIO: read-text(1), read-text(2), read-text-lines(1), read-text-lines(2),
// read-text(3-fallback), read-text-lines(3-fallback),
// read-binary(1), read-binary(2), read-binary(3)
new FunctionDef(FileIO.signatures[0], FileIO.class),
new FunctionDef(FileIO.signatures[1], FileIO.class),
new FunctionDef(FileIO.signatures[2], FileIO.class),
new FunctionDef(FileIO.signatures[3], FileIO.class),
new FunctionDef(FileIO.signatures[4], FileIO.class),
new FunctionDef(FileIO.signatures[5], FileIO.class),
new FunctionDef(FileIO.signatures[6], FileIO.class),
new FunctionDef(FileIO.signatures[7], FileIO.class),
new FunctionDef(FileIO.signatures[8], FileIO.class),

// FileWrite: write(2), write(3), write-text(2), write-text(3),
// write-text-lines(2), write-text-lines(3), write-binary(2), write-binary(3)
new FunctionDef(FileWrite.signatures[0], FileWrite.class),
new FunctionDef(FileWrite.signatures[1], FileWrite.class),
new FunctionDef(FileWrite.signatures[2], FileWrite.class),
new FunctionDef(FileWrite.signatures[3], FileWrite.class),
new FunctionDef(FileWrite.signatures[4], FileWrite.class),
new FunctionDef(FileWrite.signatures[5], FileWrite.class),
new FunctionDef(FileWrite.signatures[6], FileWrite.class),
new FunctionDef(FileWrite.signatures[7], FileWrite.class),

// FileAppend: append(2), append(3), append-binary, append-text(2), append-text(3),
// append-text-lines(2), append-text-lines(3)
new FunctionDef(FileAppend.signatures[0], FileAppend.class),
new FunctionDef(FileAppend.signatures[1], FileAppend.class),
new FunctionDef(FileAppend.signatures[2], FileAppend.class),
new FunctionDef(FileAppend.signatures[3], FileAppend.class),
new FunctionDef(FileAppend.signatures[4], FileAppend.class),
new FunctionDef(FileAppend.signatures[5], FileAppend.class),
new FunctionDef(FileAppend.signatures[6], FileAppend.class),

// FileManipulation: copy, move, delete(1), delete(2), create-dir,
// create-temp-dir(2), create-temp-dir(3),
// create-temp-file(2), create-temp-file(3),
// list(1), list(2), list(3),
// children, descendants, list-roots
new FunctionDef(FileManipulation.signatures[0], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[1], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[2], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[3], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[4], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[5], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[6], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[7], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[8], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[9], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[10], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[11], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[12], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[13], FileManipulation.class),
new FunctionDef(FileManipulation.signatures[14], FileManipulation.class),

// FilePaths: name, parent, path-to-native, path-to-uri, resolve-path(1), resolve-path(2)
new FunctionDef(FilePaths.signatures[0], FilePaths.class),
new FunctionDef(FilePaths.signatures[1], FilePaths.class),
new FunctionDef(FilePaths.signatures[2], FilePaths.class),
new FunctionDef(FilePaths.signatures[3], FilePaths.class),
new FunctionDef(FilePaths.signatures[4], FilePaths.class),
new FunctionDef(FilePaths.signatures[5], FilePaths.class),

// FileSystemProperties: dir-separator, line-separator, path-separator,
// temp-dir, base-dir, current-dir
new FunctionDef(FileSystemProperties.signatures[0], FileSystemProperties.class),
new FunctionDef(FileSystemProperties.signatures[1], FileSystemProperties.class),
new FunctionDef(FileSystemProperties.signatures[2], FileSystemProperties.class),
new FunctionDef(FileSystemProperties.signatures[3], FileSystemProperties.class),
new FunctionDef(FileSystemProperties.signatures[4], FileSystemProperties.class),
new FunctionDef(FileSystemProperties.signatures[5], FileSystemProperties.class)
};

public ExpathFileModule(final Map<String, List<? extends Object>> parameters) {
super(functions, parameters);
}

@Override
public String getNamespaceURI() {
return NAMESPACE_URI;
}

@Override
public String getDefaultPrefix() {
return PREFIX;
}

@Override
public String getDescription() {
return "EXPath File Module 4.0 - http://expath.org/ns/file";
}

@Override
public String getReleaseVersion() {
return RELEASED_IN_VERSION;
}
}
Loading
Loading