/** * Returns the open ZipFile at the given path. If the ZipFile * does not yet exist, it is created, opened, and added to the cache * of open ZipFiles. * * The path must be a file system path if representing an external * zip/jar, or it must be an absolute workspace relative path if * representing a zip/jar inside the workspace. * * @exception CoreException If unable to create/open the ZipFile */ public ZipFile getZipFile(IPath path) throws CoreException { return getZipFile(path, true); }
/** * Returns the open ZipFile at the given path. If the ZipFile * does not yet exist, it is created, opened, and added to the cache * of open ZipFiles. * * The path must be a file system path if representing an external * zip/jar, or it must be an absolute workspace relative path if * representing a zip/jar inside the workspace. * * @exception CoreException If unable to create/open the ZipFile. The * cause will be a {@link ZipException} if the file was corrupt, a * {@link FileNotFoundException} if the file does not exist, or a * {@link IOException} if we were unable to read the file. */ public ZipFile getZipFile(IPath path) throws CoreException { return getZipFile(path, true); }
/** * Returns the open ZipFile at the given path. If the ZipFile * does not yet exist, it is created, opened, and added to the cache * of open ZipFiles. * * The path must be a file system path if representing an external * zip/jar, or it must be an absolute workspace relative path if * representing a zip/jar inside the workspace. * * @exception CoreException If unable to create/open the ZipFile. The * cause will be a {@link ZipException} if the file was corrupt, a * {@link FileNotFoundException} if the file does not exist, or a * {@link IOException} if we were unable to read the file. */ public ZipFile getZipFile(IPath path) throws CoreException { return getZipFile(path, true); }
@Override public ZipFile produce() throws IOException { try { return JavaModelManager.getJavaModelManager().getZipFile(externalAnnotationPath); // use (absolute, but) unresolved path here } catch (CoreException e) { throw new IOException("Failed to read annotation file for "+typeName+" from "+externalAnnotationPath.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$ } }});
@Override public ZipFile produce() throws IOException { try { return JavaModelManager.getJavaModelManager().getZipFile(externalAnnotationPath); // use (absolute, but) unresolved path here } catch (CoreException e) { throw new IOException("Failed to read annotation file for "+typeName+" from "+externalAnnotationPath.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$ } }}); } catch (IOException e) {
@Override public ZipFile produce() throws IOException { try { return JavaModelManager.getJavaModelManager().getZipFile(externalAnnotationPath); // use (absolute, but) unresolved path here } catch (CoreException e) { throw new IOException("Failed to read annotation file for "+typeName+" from "+externalAnnotationPath.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$ } }});
public boolean isInvalidArchive(IPath path) { if (this.invalidArchives == null) return false; Long evictionTime = this.invalidArchives.get(path); if (evictionTime == null) return false; long now = System.currentTimeMillis(); // If the TTL for this cache entry has expired, directly check whether the archive is still invalid. // If it transitioned to being valid, remove it from the cache and force an update to project caches. if (now > evictionTime) { try { getZipFile(path, false); removeFromInvalidArchiveCache(path); return false; } catch (CoreException e) { // Archive is still invalid, fall through to reporting it is invalid. } } return true; }
@Override protected InputStream getContents(URI uri, IProject project) throws CoreException { // inspired by org.eclipse.jdt.internal.core.JarEntryFile.getContents() JavaModelManager modelManager = JavaModelManager.getJavaModelManager(); ZipFile zipFile = modelManager.getZipFile(zipFilePath); try { ZipEntry zipEntry = zipFile.getEntry(uri.toString()); if (zipEntry != null) { byte[] contents = Util.getZipEntryByteContent(zipEntry, zipFile); return new ByteArrayInputStream(contents); } } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, "", e.getMessage(), e)); } finally { modelManager.closeZipFile(zipFile); } return null; }
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
/** * Returns the underlying ZipFile for this Jar package fragment root. * * @exception CoreException if an error occurs accessing the jar */ public ZipFile getJar() throws CoreException { return JavaModelManager.getJavaModelManager().getZipFile(getPath()); } /**
public ArchiveValidity getArchiveValidity(IPath path) { InvalidArchiveInfo invalidArchiveInfo; synchronized (this.invalidArchivesMutex) { invalidArchiveInfo = this.invalidArchives.get(path); } if (invalidArchiveInfo == null) return ArchiveValidity.VALID; long now = System.currentTimeMillis(); // If the TTL for this cache entry has expired, directly check whether the archive is still invalid. // If it transitioned to being valid, remove it from the cache and force an update to project caches. if (now > invalidArchiveInfo.evictionTimestamp) { try { getZipFile(path, false); removeFromInvalidArchiveCache(path); } catch (CoreException e) { // Archive is still invalid, fall through to reporting it is invalid. } // Retry the test from the start, now that we have an up-to-date result return getArchiveValidity(path); } return invalidArchiveInfo.reason; }
public ArchiveValidity getArchiveValidity(IPath path) { InvalidArchiveInfo invalidArchiveInfo; synchronized (this.invalidArchivesMutex) { invalidArchiveInfo = this.invalidArchives.get(path); } if (invalidArchiveInfo == null) return ArchiveValidity.VALID; long now = System.currentTimeMillis(); // If the TTL for this cache entry has expired, directly check whether the archive is still invalid. // If it transitioned to being valid, remove it from the cache and force an update to project caches. if (now > invalidArchiveInfo.evictionTimestamp) { try { getZipFile(path, false); removeFromInvalidArchiveCache(path); } catch (CoreException e) { // Archive is still invalid, fall through to reporting it is invalid. } // Retry the test from the start, now that we have an up-to-date result return getArchiveValidity(path); } return invalidArchiveInfo.reason; }
public void verifyArchiveContent(IPath path) throws CoreException { if (isInvalidArchive(path)) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } ZipFile file = getZipFile(path); closeZipFile(file); }
public void verifyArchiveContent(IPath path) throws CoreException { if (isInvalidArchive(path)) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } ZipFile file = getZipFile(path); closeZipFile(file); }
public void verifyArchiveContent(IPath path) throws CoreException { if (isInvalidArchive(path)) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } ZipFile file = getZipFile(path); closeZipFile(file); }
public void verifyArchiveContent(IPath path) throws CoreException { if (isInvalidArchive(path)) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } ZipFile file = getZipFile(path); closeZipFile(file); }