Package org.fcrepo.server.errors

Examples of org.fcrepo.server.errors.LowlevelStorageException


    @Override
    public boolean exists(String pid) throws LowlevelStorageException {
        try {
            return hashtable.containsKey(pid);
        } catch (Exception e) {
            throw new LowlevelStorageException(true, "SimplePathRegistry.exists("
                    + pid + ")", e);
        }
    }
View Full Code Here


    public String get(String pid) throws LowlevelStorageException {
        String result;
        try {
            result = hashtable.get(pid);
        } catch (Exception e) {
            throw new LowlevelStorageException(true, "SimplePathRegistry.get("
                    + pid + ")", e);
        }
        if (null == result || 0 == result.length()) {
            throw new ObjectNotInLowlevelStorageException("SimplePathRegistry.get("
                    + pid + "): object not found");
View Full Code Here

    @Override
    public void put(String pid, String path) throws LowlevelStorageException {
        try {
            hashtable.put(pid, path);
        } catch (Exception e) {
            throw new LowlevelStorageException(true, "SimplePathRegistry.put("
                    + pid + ")", e);
        }
    }
View Full Code Here

    @Override
    public void remove(String pid) throws LowlevelStorageException {
        try {
            hashtable.remove(pid);
        } catch (Exception e) {
            throw new LowlevelStorageException(true,
                                               "SimplePathRegistry.remove("
                                                       + pid + ")",
                                               e); // <<===
        }
    }
View Full Code Here

        } catch (Exception e) {
            hashtable = temp;
            if (report != NO_REPORT) {
                logger.error("ending rebuild unsuccessfully", e);
            }
            throw new LowlevelStorageException(true,
                                               "ending rebuild unsuccessfully",
                                               e); //<<====
        }
    }
View Full Code Here

        String path = "";
        try {
            path = file.getCanonicalPath() + suffix;
            temp = new File(path);
        } catch (Exception e) {
            throw new LowlevelStorageException(true,
                                               "GenericFileSystem.wrappedNewFile(): couldn't create File for ["
                                                       + path + "]",
                                               e);
        }
        return temp;
View Full Code Here

            File containingDirectories = null;
            try {
                containingDirectories = file.getParentFile();
                containingDirectories.mkdirs();
            } catch (Exception e) {
                throw new LowlevelStorageException(true,
                                                   "GenericFileSystem.write(): couldn't make directories for ["
                                                           + getPath(file)
                                                           + "]",
                                                   e);
            }
View Full Code Here

            throws LowlevelStorageException {
        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(file);
        } catch (Exception eCaughtFileNotCreated) {
            throw new LowlevelStorageException(true, "couldn't create file "
                    + getPath(file), eCaughtFileNotCreated);
        }
        try {
            boolean fileCopySuccessful = FileUtils.copy(content, fileOutputStream);

            if(!fileCopySuccessful) {
                throw new LowlevelStorageException(true, "couldn't write new file "
                        + getPath(file));
            }
        } finally {
            try {
                fileOutputStream.close();
                content.close();
            } catch (Exception eCaughtFileNotClosed) {
                throw new LowlevelStorageException(true,
                                                   "couldn't close new file "
                                                     + getPath(file),
                                                   eCaughtFileNotClosed);
            }
        }
View Full Code Here

        if (!file.renameTo(backupFile)) {
            try {
                content.close();
            } catch (IOException e) {
            }
            throw new LowlevelStorageException(true, "failed to rename with "
                    + ".bak extension " + getPath(file));
        }

        boolean needToRevert = false;
        String err = null;
        FileOutputStream out = null;

        try {
            out = new FileOutputStream(file);
            boolean fileCopySuccessful = FileUtils.copy(content, out);
            if(!fileCopySuccessful) {
                needToRevert = true;
                err = "failed to write content to file " + file.getPath();
            }
        } catch (IOException e) {
            needToRevert = true;
            err = "failed to write content to file " + file.getPath();
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    logger.warn("Could not close file for writing "
                            + file.getPath(), e);
                }
            }
            try {
                content.close();
            } catch (IOException e) {
                logger.warn("Could not close content stream for reading", e);
            }
        }

        if (needToRevert) {
            if (backupFile.renameTo(file)) {
                err += ", so reverted to original";
            } else {
                err += ", AND failed to revert to original from .bak!";
            }
            throw new LowlevelStorageException(true, err);
        } else {
            if (!backupFile.delete()) {
                logger.warn("Could not delete backup file {}",
                        backupFile.getPath());
            }
View Full Code Here

    public final InputStream read(File file) throws LowlevelStorageException {
        //buffered reader?
        FileInputStream fileInputStream = null;
        {
            if (!file.exists()) {
                throw new LowlevelStorageException(true, "file "
                        + getPath(file) + "doesn't exist for reading");
            }
            if (!file.canRead()) {
                throw new LowlevelStorageException(true, "file "
                        + getPath(file) + "not readable");
            }

            try {
                fileInputStream = new FileInputStream(file);
            } catch (IOException eCaughtOpenFile) {
                throw new LowlevelStorageException(true,
                                                   "file "
                                                           + getPath(file)
                                                           + "couldn't be opened for reading",
                                                   eCaughtOpenFile);
            }
View Full Code Here

TOP

Related Classes of org.fcrepo.server.errors.LowlevelStorageException

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.