public boolean updateIndex()

in remoting/ide/downloadable/src/org/netbeans/modules/jackpot30/remoting/downloadable/DownloadedIndexPatcherImpl.java [48:100]


    public boolean updateIndex(URL sourceRoot, URL indexFolder) {
        try {
            File cache = new File(indexFolder.toURI());
            File checksums = new File(cache, "java/15/checksums.properties");

            if (!checksums.canRead()) return true; //nothing to fix

            FileObject srcFolderFO = URLMapper.findFileObject(sourceRoot);

            if (srcFolderFO == null) return false;

            Properties cs = loadProperties(checksums);

            if (cs.isEmpty()) return true; //apparently nothing to do

            //XXX HACK:
            String origPrefix = null;
            String in = (String) cs.keySet().iterator().next();

            int idx = Integer.MAX_VALUE;

            while ((idx = in.lastIndexOf('/', idx - 1)) != (-1)) {
                FileObject foundChild = srcFolderFO.getFileObject(in.substring(idx + 1));
                if (foundChild != null && foundChild.canRead()) {
                    origPrefix = in.substring(0, idx + 1);
                    break;
                }
            }

            if (origPrefix == null) {
                //cannot find the original prefix
                return false;
            }

            String newPrefix = srcFolderFO.toURL().toString();

            fixAbsolutePath(checksums, origPrefix, newPrefix);
            fixAbsolutePath(new File(cache, "java/15/fqn2files.properties"), origPrefix, newPrefix);

            if (srcFolderFO != null) {
                verifyAttributes(srcFolderFO, indexFolder, false);
                ensureSourcePath(srcFolderFO, indexFolder);
            }

            return true;
        } catch (URISyntaxException ex) {
            Logger.getLogger(DownloadedIndexPatcherImpl.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        } catch (IOException ex) {
            Logger.getLogger(DownloadedIndexPatcherImpl.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }