Package uk.gov.nationalarchives.droid.profile

Examples of uk.gov.nationalarchives.droid.profile.AbstractProfileResource


        SubmissionThrottle throttle = mock(SubmissionThrottle.class);
        fileEventHandler.setSubmissionThrottle(throttle);
       
        File file = new File("test_sig_files/DROID 5  Architecture.doc");
        URI uri = file.toURI();
        AbstractProfileResource resource = mock(AbstractProfileResource.class);
        when(resource.getUri()).thenReturn(uri);
       
        ProfileResourceNode node = mock(ProfileResourceNode.class);
        when(node.getUri()).thenReturn(uri);
       
        ArgumentCaptor<IdentificationRequest> requestCaptor = ArgumentCaptor.forClass(IdentificationRequest.class);
View Full Code Here


        ProfileInstance profile = selectedProfile.getProfile();
        ProfileSpec profileSpec = profile.getProfileSpec();
       
        DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
        for (File selectedFile : selectedFiles) {
            AbstractProfileResource newResource;
           
            // VERY basic shortcut detection:
            boolean isShortcut = !selectedFile.toURI().getPath().endsWith("/");
            if (selectedFile.isDirectory() && !isShortcut) {
                newResource = new DirectoryProfileResource(selectedFile, recursive);
            } else {
                newResource = new FileProfileResource(selectedFile);
            }

            if (profile.addResource(newResource)) {
                ProfileResourceNode primordialNode = new ProfileResourceNode(newResource.getUri());
                final NodeMetaData metaData = primordialNode.getMetaData();
                metaData.setName(newResource.getUri().getPath());
                metaData.setNodeStatus(NodeStatus.NOT_DONE);
                metaData.setResourceType(
                        newResource.isDirectory() ? ResourceType.FOLDER : ResourceType.FILE);

                DefaultMutableTreeNode node = new DefaultMutableTreeNode(primordialNode, false);
                int index = rootNode.getChildCount();
                treeModel.insertNodeInto(node, rootNode, index);
            }
View Full Code Here

            fastForward = true;
            startIndex = resources.indexOf(walkState.getCurrentResource());
        }
       
        for (int i = startIndex; i < resources.size(); i++) {
            AbstractProfileResource resource = resources.get(i);
            if (!fastForward) {
                walkState.setCurrentResource(resource);
                walkState.setCurrentFileWalker(null);
            }
           
            if (cancelled) {
                break;
            }
           
            if (resource.isDirectory()) {
                FileWalker fileWalker;
                if (!fastForward) {
                    walkState.setCurrentFileWalker(new FileWalker(resource.getUri(), resource.isRecursive()));
                }
               
                fileWalker = walkState.getCurrentFileWalker();
               
                fileWalker.setFileHandler(new FileWalkerHandler() {

                    @Override
                    public ResourceId handle(File file, int depth, ProgressEntry parent) {
                        progressMonitor.startJob(file.toURI());
                        ResourceId parentId = parent == null ? null : parent.getResourceId();
                        fileEventHandler.onEvent(file, parentId, null);
                        return null;
                    }
                });
               
                fileWalker.setDirectoryHandler(new FileWalkerHandler() {
                    @Override
                    public ResourceId handle(File file, int depth, ProgressEntry parent) {
                        progressMonitor.startJob(file.toURI());
                        ResourceId parentId = parent == null ? null : parent.getResourceId();
                        return directoryEventHandler.onEvent(file, parentId, depth, false);
                    }
                });
               
                fileWalker.setRestrictedDirectoryHandler(new FileWalkerHandler() {
                    @Override
                    public ResourceId handle(File file, int depth, ProgressEntry parent) {
                        progressMonitor.startJob(file.toURI());
                        ResourceId parentId = parent == null ? null : parent.getResourceId();
                        return directoryEventHandler.onEvent(file, parentId, depth, true);
                    }
                });
               
                walkState.setWalkStatus(WalkStatus.IN_PROGRESS);
                fileWalker.walk();
            } else {
                progressMonitor.startJob(resource.getUri());
                fileEventHandler.onEvent(new File(resource.getUri()), null, null);
            }
           
            fastForward = false;
        }
        walkState.setWalkStatus(WalkStatus.FINISHED);
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.profile.AbstractProfileResource

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.