throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.compressedRarNotSupportedInModuleRA(moduleName)); } else { child = VFS.getChild(path.getPath().split("META-INF")[0]); closable = VFS.mountReal(new File(path.getPath().split("META-INF")[0]), child); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(child, mountHandle); final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot == null || !deploymentRoot.exists()) return; ConnectorXmlDescriptor connectorXmlDescriptor = RaDeploymentParsingProcessor.process(resolveProperties, deploymentRoot, null, name); Map<ResourceRoot, Index> annotationIndexes = new HashMap<ResourceRoot, Index>(); ResourceRootIndexer.indexResourceRoot(resourceRoot); Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX); if (index != null) { annotationIndexes.put(resourceRoot, index);
final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot == null || !deploymentRoot.exists()) { return; final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); if (!deploymentRootName.endsWith(SAR_EXTENSION)) { return; Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); try { final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER); Closeable closable = NO_OP_CLOSEABLE; if(overlay != null) { overlay.remountAsZip(false); } else if(child.isFile()) { closable = VFS.mountZip(child, child, TempFileProviderService.provider()); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(child, mountHandle); ModuleRootMarker.mark(childResource); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, childResource); resourceRoot.addToAttachmentList(Attachments.INDEX_IGNORE_PATHS, child.getPathNameRelativeTo(deploymentRoot));
private static Closeable mount(VirtualFile moduleFile, boolean explode) throws IOException { return explode ? VFS.mountZipExpanded(moduleFile, moduleFile, TempFileProviderService.provider()) : VFS.mountZip(moduleFile, moduleFile, TempFileProviderService.provider()); }
case XMLStreamConstants.END_ELEMENT: { try { final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentRootFile = deploymentRoot.getRoot(); final VirtualFile child = deploymentRootFile.getChild(path); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); MountedDeploymentOverlay overlay = overlays.get(path); Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if(child.isFile()) { closable = VFS.mountZip(child, child, TempFileProviderService.provider()); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(name, child, mountHandle); for (final FilterSpecification filter : resourceFilters) { resourceRoot.getExportFilters().add(filter); resourceRoot.setUsePhysicalCodeSource(usePhysicalCodeSource);
final List<ResourceRoot> entries = new ArrayList<ResourceRoot>(); final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES); if (webinfClasses.exists()) { final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null); ModuleRootMarker.mark(webInfClassesRoot); entries.add(webInfClassesRoot); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB); if (webinfLib.exists()) { Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if (archive.isFile()) { closable = VFS.mountZip(archive, archive, TempFileProviderService.provider()); } else { closable = null; final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable)); ModuleRootMarker.mark(webInfArchiveRoot); entries.add(webInfArchiveRoot);
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); VirtualFile mountPoint = deploymentRoot.getRoot().getChild(path); VirtualFile parent = mountPoint.getParent(); while (!parent.exists()) { parent = parent.getParent(); Closeable closable = VFS.mountTemp(file, TempFileProviderService.provider()); deploymentUnit.addToAttachmentList(MOUNTED_FILES, closable); Closeable handle = VFS.mountReal(content.getPhysicalFile(), mountPoint); MountedDeploymentOverlay mounted = new MountedDeploymentOverlay(handle, content.getPhysicalFile(), mountPoint, TempFileProviderService.provider()); deploymentUnit.addToAttachmentList(MOUNTED_FILES, mounted); mounts.put(path, mounted); } else {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getAttachment( Attachments.DEPLOYMENT_ROOT ) != null || !deploymentUnit.getName().endsWith( this.fileSuffix )) { return; final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment( Attachments.SERVER_DEPLOYMENT_REPOSITORY ); if(deploymentMountProvider == null) { throw new DeploymentUnitProcessingException( "No deployment repository available." ); String deploymentName = deploymentUnit.getName(); final VirtualFile deploymentRoot = VFS.getChild( "content/" + deploymentName ); Closeable handle = null; final MountHandle mountHandle; try { handle = deploymentMountProvider.mountDeploymentContent( deploymentContents, deploymentRoot, MountType.REAL ); mountHandle = new MountHandle( handle ); } catch (IOException e) { failed = true; final ResourceRoot resourceRoot = new ResourceRoot( deploymentRoot, mountHandle ); deploymentUnit.putAttachment( Attachments.DEPLOYMENT_ROOT, resourceRoot ); deploymentUnit.putAttachment( DESCRIPTOR_ROOT, resourceRoot );
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); deploymentUnit.putAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS, mounts); final AttachmentList<ResourceRoot> rootList = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS); resourceRootMap.put(root.getRoot().getPathNameRelativeTo(deploymentRoot.getRoot()), root); VirtualFile mountPoint = deploymentRoot.getRoot().getChild(override.getPath()); copyFile(override.getContentHash().getPhysicalFile(), mountPoint.getPhysicalFile()); Closeable handle = VFS.mountReal(override.getContentHash().getPhysicalFile(), mountPoint); MountedDeploymentOverlay mounted = new MountedDeploymentOverlay(handle, override.getContentHash().getPhysicalFile(), mountPoint, TempFileProviderService.provider()); deploymentUnit.addToAttachmentList(MOUNTED_FILES, mounted); mounts.put(override.getPath(), mounted);
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; } final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final Set<String> paths = new HashSet<String>(); for (final DeploymentOverlayService deploymentOverlay : indexService.getOverrides(deploymentUnit.getName())) { for (final ContentService override : deploymentOverlay.getContentServices()) { if (!paths.contains(override.getPath())) { paths.add(override.getPath()); try { Closeable handle = VFS.mountReal(override.getContentHash().getPhysicalFile(), deploymentRoot.getRoot().getChild(override.getPath())); deploymentUnit.addToAttachmentList(MOUNTED_FILES, handle); } catch (IOException e) { throw ServerMessages.MESSAGES.deploymentOverlayFailed(e, deploymentOverlay.getName(), override.getPath()); } } } } }
final VirtualFile file = VFS.getChild(candidate); Closeable handle = null; TempFileProvider provider = null; if (file.exists()) if (file.isDirectory()) handle = VFS.mountReal(file.getPhysicalFile(), file); handle = VFS.mountZip(file.getPhysicalFile(), file, provider);
private void traverse(String dir, String padding, boolean first) throws java.io.IOException { VirtualFile path = VFS.getChild(dir); buf.append(path.getName()); buf.append("\n"); List<VirtualFile> files = path.getChildren(); for (VirtualFile f : files ) { count += 1; if (f.getPathName().startsWith(".")) { continue;
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * * @param file The file for which the resource root will be created * @return Returns the created {@link ResourceRoot} * @throws java.io.IOException */ private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { try { Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); String relativeName = file.getPathNameRelativeTo(deploymentRoot); MountedDeploymentOverlay overlay = overlays.get(relativeName); Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if(file.isFile()) { closable = VFS.mountZip(file, file, TempFileProviderService.provider()); } final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); ModuleRootMarker.mark(resourceRoot); ResourceRootIndexer.indexResourceRoot(resourceRoot); return resourceRoot; } catch (IOException e) { throw new RuntimeException(e); } }
private VirtualFile getFile(URL url) { try { return VFS.getChild(url.toURI()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * * @param file The file for which the resource root will be created * @return Returns the created {@link ResourceRoot} * @throws java.io.IOException */ private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { try { Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); String relativeName = file.getPathNameRelativeTo(deploymentRoot); MountedDeploymentOverlay overlay = overlays.get(relativeName); Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if(file.isFile()) { closable = VFS.mountZip(file, file, TempFileProviderService.provider()); } final MountHandle mountHandle = MountHandle.create(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); ModuleRootMarker.mark(resourceRoot); ResourceRootIndexer.indexResourceRoot(resourceRoot); return resourceRoot; } catch (IOException e) { throw new RuntimeException(e); } }
public VFSArchive(URL rootUrl, String descriptorLocation) throws URISyntaxException, IOException { this.rootUrl = rootUrl; this.descriptorLocation = descriptorLocation; root = VFS.getChild(rootUrl.toURI()); List<VirtualFile> children = root.getChildrenRecursively(new VirtualFileFilter() { @Override public boolean accepts(VirtualFile file) { return file.isFile(); } }); files = new HashMap<String, VirtualFile>(); for (VirtualFile file : children) { files.put(file.getPathNameRelativeTo(root), file); } }
static MountHandle extractArchive(File archive, TempFileProvider tempFileProvider, String name) throws IOException { return ((MountHandle) VFS.mountZipExpanded(archive, VFS.getChild(name), tempFileProvider)); }
/** * Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file * system when closed. * * @param zipFile a zip file in the VFS * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountZip(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { return mountZip(zipFile.openStream(), zipFile.getName(), mountPoint, tempFileProvider); }
/** * Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and * close the filesystem when closed. The given zip data stream is closed. * * @param zipFile a zip file in the VFS * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountZipExpanded(VirtualFile zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { return mountZipExpanded(zipFile.openStream(), zipFile.getName(), mountPoint, tempFileProvider); }
VirtualFile mountPoint = VFS.getRootVirtualFile().getChild(deployment.getName()); Closeable closeable = VFS.mountZipExpanded(in, deployment.getName(), mountPoint, tempFileProvider); this.mountPoints.add(closeable);