Examples of FileDetails


Examples of org.springframework.roo.file.monitor.event.FileDetails

                        final File thisFile = entry.getKey();
                        final Long currentTimestamp = entry.getValue();
                        if (!priorFiles.containsKey(thisFile)) {
                            // This file did not exist last execution, so it
                            // must be new
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.CREATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyCreated.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                            continue;
                        }

                        final Long previousTimestamp = priorFiles.get(thisFile);
                        if (!currentTimestamp.equals(previousTimestamp)) {
                            // Modified
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.UPDATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyChanged.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                        }
                    }

                    // Now locate deleted files
                    priorFiles.keySet().removeAll(currentExecution.keySet());
                    for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                        final File deletedFile = entry.getKey();
                        eventsToPublish.add(new FileEvent(new FileDetails(
                                deletedFile, entry.getValue()),
                                FileOperation.DELETED, null));
                        try {
                            // If this file was already going to be notified,
                            // there is no need to do it twice
                            notifyDeleted
                                    .remove(deletedFile.getCanonicalPath());
                        }
                        catch (final IOException ignored) {
                        }
                    }
                }
                else {
                    // No data from previous execution, so it's a
                    // newly-monitored location
                    for (final Entry<File, Long> entry : currentExecution
                            .entrySet()) {
                        eventsToPublish.add(new FileEvent(new FileDetails(entry
                                .getKey(), entry.getValue()),
                                FileOperation.MONITORING_START, null));
                    }
                }

                // Record the monitored location's contents, ready for next
                // execution
                priorExecution.put(request, currentExecution);

                // We can discard the created and deleted notifications, as they
                // would have been correctly discovered in the above loop
                notifyCreated.clear();
                notifyDeleted.clear();

                // Explicitly handle any undiscovered update notifications, as
                // this indicates an identical millisecond update occurred
                for (final String canonicalPath : notifyChanged) {
                    final File file = new File(canonicalPath);
                    eventsToPublish.add(new FileEvent(new FileDetails(file,
                            file.lastModified()), FileOperation.UPDATED, null));
                }
                notifyChanged.clear();
                publish(eventsToPublish);
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileDetails

    public String getRelativeSegment(final String identifier) {
        final PhysicalPath parent = getApplicablePhysicalPath(identifier);
        if (parent == null) {
            return null;
        }
        final FileDetails parentFile = new FileDetails(parent.getLocation(),
                null);
        return parentFile.getRelativeSegment(identifier);
    }
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileDetails

                    && removeTrailingSeparator(pom.getRoot()).length() > longest) {
                longest = removeTrailingSeparator(pom.getRoot()).length();
                int nextLongest = 0;
                for (final PhysicalPath thisPhysicalPath : pom
                        .getPhysicalPaths()) {
                    final String possibleParent = new FileDetails(
                            thisPhysicalPath.getLocation(), null)
                            .getCanonicalPath();
                    if (removeTrailingSeparator(identifier).startsWith(
                            possibleParent)
                            && possibleParent.length() > nextLongest) {
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileDetails

        if (!fileManager.exists(persistenceXmlPath)) {
            throw new IllegalStateException("Failed to find "
                    + persistenceXmlPath);
        }

        final FileDetails fileDetails = fileManager
                .readFile(persistenceXmlPath);
        Document document = null;
        try {
            final InputStream is = new BufferedInputStream(new FileInputStream(
                    fileDetails.getFile()));
            final DocumentBuilder builder = XmlUtils.getDocumentBuilder();
            builder.setErrorHandler(null);
            document = builder.parse(is);
        }
        catch (final Exception e) {
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileDetails

            fileMonitorService.notifyCreated(actual.getCanonicalPath());
        }
        catch (final IOException ignored) {
        }
        new CreateDirectory(undoManager, filenameResolver, actual);
        return new FileDetails(actual, actual.lastModified());
    }
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileDetails

        Validate.notNull(fileIdentifier, "File identifier required");
        final File f = new File(fileIdentifier);
        if (!f.exists()) {
            return null;
        }
        return new FileDetails(f, f.lastModified());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.