CCM NG: Interface for CcmFiles
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4639 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
6b190c9d4e
commit
7f94ce6f97
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
|
||||
/**
|
||||
* This class provides access to the file (local) system. If available an
|
||||
* implementation of the {@link FileSystemAdapter} interface is used. The
|
||||
* implementations of {@link FileSystemAdapter} provide a (transaction) safe way
|
||||
* to access the local file system. If no implementation of
|
||||
* {@link FileSystemAdapter} is available this class will use
|
||||
* {@link java.nio.file.Path} etc. as fallback. Depending on your application
|
||||
* server access to the local file system using these classes may fail. For
|
||||
* information about how to deploy and configure a specific implementation of
|
||||
* {@link FileSystemAdapter} please refer the the documentation of the
|
||||
* implementation.
|
||||
*
|
||||
* The method in this class encapsulate the details of the access to the local
|
||||
* file system. Therefore the paths to the files to read are usually provided as
|
||||
* strings.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class CcmFiles {
|
||||
|
||||
/**
|
||||
* Creates a {@link Reader} for the provided {@code path}.
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public Reader createReader(final String path)
|
||||
throws FileDoesNotExistException,
|
||||
FileAccessException,
|
||||
InsufficientPermissionsException {
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Writer} for the provided {@code path}.
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public Writer createWriter(final String path)
|
||||
throws FileAccessException, InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link InputStream} for the provided {@code path}.
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public InputStream createInputStream(final String path)
|
||||
throws FileDoesNotExistException,
|
||||
FileAccessException,
|
||||
InsufficientPermissionsException {
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link OutputStream} for the provided {@code path}.
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public OutputStream createOutputStream(final String path)
|
||||
throws FileAccessException, InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a file exists.
|
||||
*
|
||||
* @param path
|
||||
* @return {@code true} if a file with the provided {@code path} exists,
|
||||
* {@code false} otherwise.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public boolean existsFile(final String path)
|
||||
throws FileAccessException, InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the provided path points to a directory.
|
||||
*
|
||||
* @param path
|
||||
* @return {@code true} if the the file to which the provided path points
|
||||
* exists and is a directory, {@code false} otherwise.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
*/
|
||||
public boolean isDirectory(final String path)
|
||||
throws FileAccessException,
|
||||
FileDoesNotExistException,
|
||||
InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory at the provided path.
|
||||
*
|
||||
* @param path The path of the new directory.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.FileAlreadyExistsException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public void createDirectory(final String path)
|
||||
throws FileAccessException,
|
||||
FileAlreadyExistsException,
|
||||
InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* List the files in a directory.
|
||||
*
|
||||
* @param path The {@code path} of the directory.
|
||||
* @return A list of the names of the files in the directory.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public List<String> listFiles(final String path)
|
||||
throws FileAccessException,
|
||||
FileDoesNotExistException,
|
||||
InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file or directory. If the file is a directory the directory must
|
||||
* be empty.
|
||||
*
|
||||
* @param path The path of the file to delete.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
* @throws org.libreccm.files.DirectoryNotEmptyException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public void deleteFile(final String path)
|
||||
throws FileAccessException,
|
||||
FileDoesNotExistException,
|
||||
DirectoryNotEmptyException,
|
||||
InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file or directory.
|
||||
*
|
||||
* @param path
|
||||
* @param recursively Delete directories recursively.
|
||||
* @throws org.libreccm.files.FileAccessException
|
||||
* @throws org.libreccm.files.FileDoesNotExistException
|
||||
* @throws org.libreccm.files.InsufficientPermissionsException
|
||||
*/
|
||||
public void deleteFile(final String path, final boolean recursively)
|
||||
throws FileAccessException,
|
||||
FileDoesNotExistException,
|
||||
InsufficientPermissionsException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Thrown if a non empty directory is not deleted recursively.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DirectoryNotEmptyException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -8515711805034123260L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>DirectoryNotEmptyException</code> without
|
||||
* detail message.
|
||||
*/
|
||||
DirectoryNotEmptyException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>DirectoryNotEmptyException</code> with
|
||||
* the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
DirectoryNotEmptyException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
DirectoryNotEmptyException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
DirectoryNotEmptyException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Generic exception thrown if an error occurs while accessing the local file
|
||||
* system which is not covered by other exceptions.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class FileAccessException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>FileAccessException</code> without detail
|
||||
* message.
|
||||
*/
|
||||
FileAccessException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>FileAccessException</code> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
FileAccessException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
FileAccessException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
FileAccessException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Thrown if a method requires that a file does not exist already but the file
|
||||
* exists.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class FileAlreadyExistsException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 2237027823060973043L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>FileAlreadyExistsException</code> without
|
||||
* detail message.
|
||||
*/
|
||||
FileAlreadyExistsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>FileAlreadyExistsException</code> with
|
||||
* the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
FileAlreadyExistsException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
FileAlreadyExistsException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
FileAlreadyExistsException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Thrown if by methods that require that the file accessed exists if the
|
||||
* requested file does not exist.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class FileDoesNotExistException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>FileDoesNotExistException</code> without
|
||||
* detail message.
|
||||
*/
|
||||
FileDoesNotExistException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>FileDoesNotExistException</code> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
FileDoesNotExistException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
FileDoesNotExistException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
FileDoesNotExistException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Thrown if the user which is used to run the application server has not the
|
||||
* necessary permissions to access the requested file.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class InsufficientPermissionsException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -7496839503615573013L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>InsufficientPermissionsException</code>
|
||||
* without detail message.
|
||||
*/
|
||||
InsufficientPermissionsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>InsufficientPermissionsException</code>
|
||||
* with the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
InsufficientPermissionsException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
InsufficientPermissionsException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
InsufficientPermissionsException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* 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.libreccm.files;
|
||||
|
||||
/**
|
||||
* Thrown if the a method expects that the requested file is a directory but is
|
||||
* not.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class NoDirectoryException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5811387600385322767L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>NoDirectoryException</code> without
|
||||
* detail message.
|
||||
*/
|
||||
NoDirectoryException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>NoDirectoryException</code> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
NoDirectoryException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
NoDirectoryException(final Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
NoDirectoryException(final String msg, final Exception ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue