Package uk.gov.nationalarchives.droid.core.interfaces

Examples of uk.gov.nationalarchives.droid.core.interfaces.ResourceId


         * @param prefixPath the path of
         */
        private ResourceId processAncestorFolders(String path) {
            // Split the path string into a list of ancestor paths:
            List<String> paths = ArchiveFileUtils.getAncestorPaths(path);
            ResourceId longestParentId = parentId;
           
            // Find the longest path we *have* seen before (if any):
            // (ancestor paths are ordered longest first)
            int longestSeenBefore = paths.size();
            ResourceId correlationId = null;
            for (int pathIndex = 0; pathIndex < paths.size(); pathIndex++) {
                correlationId = directories.get(paths.get(pathIndex));
                if (correlationId != null) {
                    longestSeenBefore = pathIndex;
                    longestParentId = correlationId;
View Full Code Here


       
        @Override
        protected void handleEntry(ZipArchiveEntry entry) throws IOException {
            String entryName = entry.getName();
            final String prefixPath = FilenameUtils.getPath(entryName);
            ResourceId correlationId = parentId; // by default, files are correlated to the parent.

            // If there is a path, get the actual correlation id for its parent folder:
            if (!prefixPath.isEmpty()) {
                correlationId = directories.get(prefixPath);
                // If we haven't seen the path before, add the ancestor folders not yet seen:
View Full Code Here

        boolean jobCountDecremented = false;
       
        String archiveFormat = getArchiveFormat(results);
        if (archiveFormat != null) {
            results.setArchive(true);
            ResourceId id = resultHandler.handle(results);
            jobCounter.incrementPostProcess();
            RequestIdentifier identifier = request.getIdentifier();
            identifier.setResourceId(id);
            if (identifier.getAncestorId() == null) {
                identifier.setAncestorId(id.getId());
            }
            submissionQueue.add(request.getIdentifier());
            jobCounter.decrement();
            jobCountDecremented = true;
            try {
                ArchiveHandler handler = archiveHandlerFactory.getHandler(archiveFormat);
                handler.handle(request);
                // CHECKSTYLE:OFF
            } catch (Exception e) {
                // CHECKSTYLE:ON
                String causeMessage = "";
                if (e.getCause() != null) {
                    causeMessage = e.getCause().getMessage();
                }
                final String message = String.format(ARCHIVE_ERROR,
                        archiveFormat, request.getIdentifier().getUri().toString(), e.getMessage(), causeMessage);
                log.warn(message);
                resultHandler.handleError(new IdentificationException(
                        request, IdentificationErrorType.OTHER, e));
            } finally {
                submissionQueue.remove(request.getIdentifier());
                jobCounter.decrementPostProcess();
            }
        } else {
            ResourceId id = resultHandler.handle(results);
            request.getIdentifier().setNodeId(id.getId());
        }
        return jobCountDecremented;
    }
View Full Code Here

                    // Are we processing archive formats?
                    if (processArchives && archiveFormatResolver != null) {
                        jobCountDecremented = handleArchive(request, results);
                    } else { // just process the results so far:
                        results.setArchive(getArchiveFormat(results) != null);
                        ResourceId id = resultHandler.handle(results);
                        request.getIdentifier().setResourceId(id);
                    }
                } else { // we have possible container formats:
                    droidCore.removeLowerPriorityHits(containerResults);
                    containerResults = handleExtensions(request, containerResults);
                    ResourceId id = resultHandler.handle(containerResults);
                    request.getIdentifier().setResourceId(id);
                }
            } catch (ExecutionException e) {
                final Throwable cause = e.getCause();
                log.error(cause.getStackTrace(), cause);
View Full Code Here

       
        @Override
        protected void handleEntry(TarArchiveEntry entry) throws IOException {
            String entryName = entry.getName();
            final String prefixPath = FilenameUtils.getPath(entryName);
            ResourceId correlationId = parentId; // by default, files are correlated to the parent.

            // If there is a path, get the actual correlation id for its parent folder:
            if (!prefixPath.isEmpty()) {
                correlationId = directories.get(prefixPath);
                // If we haven't seen the path before, add the ancestor folders not yet seen:
View Full Code Here

         * @param prefixPath the path of
         */
        private ResourceId processAncestorFolders(String path) {
            // Split the path string into a list of ancestor paths:
            List<String> paths = ArchiveFileUtils.getAncestorPaths(path);
            ResourceId longestParentId = parentId;
           
            // Find the longest path we *have* seen before (if any):
            // (ancestor paths are ordered longest first)
            int longestSeenBefore = paths.size();
            ResourceId correlationId = null;
            for (int pathIndex = 0; pathIndex < paths.size(); pathIndex++) {
                correlationId = directories.get(paths.get(pathIndex));
                if (correlationId != null) {
                    longestSeenBefore = pathIndex;
                    longestParentId = correlationId;
View Full Code Here

            }
           
            // Delete and re-submit all the distinct nodes as new requests
            for (Long ancestorId : ancestorIds) {
                ProfileResourceNode node = resultHandlerDao.loadNode(ancestorId);
                ResourceId parentId = getParentResourceId(node);
                resultHandlerDao.deleteNode(node.getId());
                File file = new File(node.getUri());
                fileEventHandler.onEvent(file, parentId, null);
            }
        }
View Full Code Here

        }
    }

   
    private ResourceId getParentResourceId(ProfileResourceNode node) {
        ResourceId id = null;
        Long parentId = node.getParentId();
        if (parentId != null) {
            String parentPrefix = node.getPrefix();
            if (parentPrefix.length() >= FIVE) {
                parentPrefix = parentPrefix.substring(0, parentPrefix.length() - FIVE);
            } else {
                parentPrefix = "";
            }
            id = new ResourceId(parentId, parentPrefix);
        }
        return id;
    }
View Full Code Here

            return;
        }
       
        ProgressEntry parent = progress.peek();
        List unprocessedChildren = Collections.EMPTY_LIST;
        ResourceId directoryId;
       
        if (recursive || depth == 0) {
            File[] children = directory.listFiles();
            if (children == null) {
                directoryId = restrictedDirectoryHandler.handle(directory, depth, parent);
View Full Code Here

        /**
         *
         * @return A resource id for the progress entry.
         */
        public ResourceId getResourceId() {
            return new ResourceId(id, prefix);
        }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.interfaces.ResourceId

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.