Package info.freelibrary.util

Examples of info.freelibrary.util.PairtreeRoot


    protected void deletePairtreeJP2Cache(final String aID) throws MojoExecutionException {
        final String jp2s = myProject.getProperties().getProperty(PAIRTREE_FS);

        try {
            final PairtreeRoot ptRoot = new PairtreeRoot(new File(jp2s));

            if (aID != null && !aID.equals("all")) {
                final PairtreeObject ptObj = ptRoot.getObject(aID);

                if (ptObj.exists()) {
                    if (!FileUtils.delete(ptObj)) {
                        LOGGER.error(BUNDLE.get("PT_TREE_DELETE", ptObj));
                    }
                }
            } else {
                if (ptRoot.exists()) {
                    if (FileUtils.delete(ptRoot)) {
                        ptRoot.mkdirs();
                    } else if (LOGGER.isErrorEnabled()) {
                        LOGGER.error(BUNDLE.get("PT_TREE_DELETE", ptRoot));
                    }
                }
            }
View Full Code Here


    protected void deletePairtreeImageCache(final String aID) throws MojoExecutionException {
        final String cache = myProject.getProperties().getProperty(PAIRTREE_CACHE);

        try {
            final PairtreeRoot ptCache = new PairtreeRoot(new File(cache));

            if (aID != null && !aID.equals("all")) {
                final PairtreeObject cacheObj = ptCache.getObject(aID);

                if (cacheObj.exists()) {
                    if (!FileUtils.delete(cacheObj)) {
                        LOGGER.error(BUNDLE.get("PT_CACHE_DELETE", cacheObj));
                    }
                }
            } else {
                if (ptCache.exists()) {
                    if (FileUtils.delete(ptCache)) {
                        ptCache.mkdirs();
                    } else if (LOGGER.isErrorEnabled()) {
                        LOGGER.error(BUNDLE.get("PT_CACHE_DELETE", ptCache));
                    }
                }
            }
View Full Code Here

    }

    private void convert(File aSource, File aDest) throws IOException, Exception {
        File[] files = aSource.listFiles(new FileExtFileFilter(myExts));
        File[] dirs = aSource.listFiles(new DirFileFilter());
        PairtreeRoot ptRoot = new PairtreeRoot(myDest); // JP2 directory
        int pathIndex = myDest.getAbsolutePath().length();

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("INGEST_DIRS_FOUND", dirs.length, aSource);
        }

        // These are the directories into which we convert our JP2s
        for (File nextSource : dirs) {
            String fileName = nextSource.getName();

            if (!fileName.startsWith(".")) {
                File dest = new File(aDest, nextSource.getName());

                if (dest.exists() && (!dest.canWrite() || !dest.isDirectory())) {
                    throw new IOException("Problem with destination directory: " + dest.getAbsolutePath());
                } else {
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("INGEST_DESCENDING", dest);
                    }

                    if ((!dest.exists() && dest.mkdirs()) || (dest.exists() && dest.isDirectory())) {
                        convert(nextSource, dest); // go into a sub-directory
                    } else {
                        throw new IOException("Failed to create a new directory: " + dest.getAbsolutePath());
                    }
                }
            }
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("INGEST_FILES_FOUND", files.length, aSource);
        }

        // These are the actual image files that we're going to convert
        for (File next : files) {
            String fileName = FileUtils.stripExt(next.getName()) + JP2_EXT;
            String sourceFileName = next.getAbsolutePath();
            File nextDest = new File(aDest, fileName); // JP2 image file

            if (next.length() > myMaxSize) {
                if (LOGGER.isErrorEnabled()) {
                    long size = next.length() / 1048576;
                    LOGGER.error("INGEST_TOO_LARGE", sourceFileName, size);
                }

                continue; // We've written to the error log, move along...
            }

            if (!aDest.exists() && !aDest.mkdirs()) {
                throw new IOException("Unable to create new directory: " + nextDest.getAbsolutePath());
            }

            if (!fileName.startsWith(".")) {
                String destFileName = nextDest.getAbsolutePath();

                // Check to see whether we've already converted this file!
                String path = FileUtils.stripExt(nextDest.getAbsolutePath());
                String id = "--" + path.substring(pathIndex);
                PairtreeObject ptDir = ptRoot.getObject(id);
                String ptFileName = PairtreeUtils.encodeID(id);
                File jp2 = new File(ptDir, ptFileName);

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("INGEST_EXISTS_CHECK", jp2);
View Full Code Here

        }
    }

    private void loadFileSystemImages(File aJP2Dir, File aSource) throws IOException, FileNotFoundException {
        FilenameFilter filter = new RegexFileFilter(JP2_FILE_PATTERN);
        PairtreeRoot pairtree = new PairtreeRoot(aJP2Dir);
        String skipped = "pairtree_root";
        Builder bob = new Builder();

        // +1 below is to lose the trailing slash; we add via "--/" below
        int pathIndex = aJP2Dir.getAbsolutePath().length() + 1;
View Full Code Here

        // Sets the Maven loggers' levels (not the levels of loggers used by this plugin)
        MavenUtils.setLogLevels(MavenUtils.ERROR_LOG_LEVEL, MavenUtils.getMavenLoggers());

        try {
            final PairtreeRoot pairtree = new PairtreeRoot(new File(ptfs));
            final RegexFileFilter filter = new RegexFileFilter(".*");
            final String eol = System.getProperty("line.separator");
            final File[] jp2List = FileUtils.listFiles(pairtree, filter, true);

            int processed = 0;
View Full Code Here

        // Sets the Maven loggers' levels (not the levels of loggers used by this plugin)
        MavenUtils.setLogLevels(MavenUtils.ERROR_LOG_LEVEL, MavenUtils.getMavenLoggers());

        try {
            final PairtreeRoot pairtree = new PairtreeRoot(new File(ptfs));

            if (myCsvFile != null && myCsvFile.exists()) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug(BUNDLE.get("INGEST_CSV", myCsvFile, myCsvPathCol, myCsvIdCol));
                }
View Full Code Here

            InputStream source = IOUtils.getInputStream(url);

            // If we know it's JP2 at this point, it's because it's been passed
            // in as one of our parsable URLs.
            if (isJp2 && myPtRootDir != null) {
                final PairtreeRoot pairtree = new PairtreeRoot(myPtRootDir);
                final PairtreeObject dir = pairtree.getObject(aReferent);
                final String filename = PairtreeUtils.encodeID(aReferent);
                FileOutputStream destination;
                boolean result;

                file = new File(dir, filename);
View Full Code Here

     * Sets up the identifier integration test.
     */
    @Before
    public void setup() {
        try {
            if (new PairtreeRoot(System.getProperty("pairtree.cache")).delete() && LOGGER.isDebugEnabled()) {
                LOGGER.debug("Deleted Pairtree root '{}' in preparation for another test", new PairtreeRoot(System
                        .getProperty("pairtree.cache")));
            }
        } catch (final IOException details) {
            fail(details.getMessage());
        }
View Full Code Here

        }
    }

    private File getPtObject(final String aID) {
        try {
            final PairtreeObject ptObj = new PairtreeRoot(System.getProperty("pairtree.cache")).getObject(aID);
            return new File(ptObj, aID); // This is the actual image file in the Pairtree object
        } catch (final IOException details) {
            fail(details.getMessage());
            return new File(System.getProperty("java.io.tmpdir"), "ptObj-" + new Date().getTime());
        }
View Full Code Here

        if (myCache != null) {
            OutputStream outStream = null;
            InputStream inStream = null;

            try {
                final PairtreeRoot cacheDir = new PairtreeRoot(new File(myCache));
                final PairtreeObject cacheObject = cacheDir.getObject(id);
                final ServletContext context = getServletContext();
                final String filename = PairtreeUtils.encodeID(id);
                final File xmlFile = new File(cacheObject, filename + ".xml");

                if (xmlFile.exists() && xmlFile.length() > 0) {
View Full Code Here

TOP

Related Classes of info.freelibrary.util.PairtreeRoot

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.