@Override public void postProcess( final Path path ) { if ( supports( path ) ) { invalidateDMOPackageCache.fire( new InvalidateDMOPackageCacheEvent( path ) ); } }
public void invalidateProjectCache(@Observes final InvalidateDMOModuleCacheEvent event) { PortablePreconditions.checkNotNull("event", event); final Module project = event.getModule(); //If resource was not within a Module there's nothing to invalidate if (project != null) { invalidateCache(project); } }
private void processResourceChange(final SessionInfo sessionInfo, final Path path, final ResourceChangeType changeType) { //Only process Project resources final Project project = projectService.resolveProject(path); if (project == null) { return; } if (logger.isDebugEnabled()) { logger.debug("Processing resource change for sessionInfo: " + sessionInfo + ", project: " + project + ", path: " + path + ", changeType: " + changeType); } if (isObservableResource(path)) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOProjectCacheEvent(sessionInfo, project, path)); } }
private void processResourceChange(final SessionInfo sessionInfo, final Path path, final ResourceChangeType changeType) { //Only process Project resources final Module module = projectService.resolveModule(path); if (module == null) { return; } if (logger.isDebugEnabled()) { logger.debug("Processing resource change for sessionInfo: " + sessionInfo + ", project: " + module + ", path: " + path + ", changeType: " + changeType); } if (isObservableResource(path)) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } }
public void invalidateModuleCache(@Observes final InvalidateDMOModuleCacheEvent event) { PortablePreconditions.checkNotNull("event", event); final Path resourcePath = event.getResourcePath(); final KieModule module = moduleService.resolveModule(resourcePath); //If resource was not within a Module there's nothing to invalidate if (module != null) { invalidateCache(module); } }
public void invalidatePackageCache(@Observes final InvalidateDMOPackageCacheEvent event) { PortablePreconditions.checkNotNull("event", event); final Path resourcePath = event.getResourcePath(); final Package pkg = moduleService.resolvePackage(resourcePath); //If resource was not within a Package there's nothing to invalidate if (pkg != null) { invalidateCache(pkg); } }
@Override public Path save( final Path resource, final String content, final Metadata metadata, final String comment ) { try { Metadata currentMetadata = metadataService.getMetadata( resource ); ioService.write( Paths.convert( resource ), content, metadataService.setUpAttributes( resource, metadata ), commentedOptionFactory.makeCommentedOption( comment ) ); //Invalidate Package-level DMO cache as a DSL has been altered invalidateDMOPackageCache.fire( new InvalidateDMOPackageCacheEvent( resource ) ); fireMetadataSocialEvents( resource, currentMetadata, metadata ); return resource; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } }
private void processResourceChange(final SessionInfo sessionInfo, final Path path, final ResourceChangeType changeType) { //Only process Project resources final Module module = projectService.resolveModule(path); if (module == null) { return; } if (logger.isDebugEnabled()) { logger.debug("Processing resource change for sessionInfo: " + sessionInfo + ", project: " + module + ", path: " + path + ", changeType: " + changeType); } if (isObservableResource(path)) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } }
private void processBatchResourceChanges(final SessionInfo sessionInfo, final Map<Path, Collection<ResourceChange>> resourceChanges) { Project project; final Map<Project, Path> pendingNotifications = new HashMap<Project, Path>(); for (final Map.Entry<Path, Collection<ResourceChange>> pathCollectionEntry : resourceChanges.entrySet()) { //Only process Project resources project = projectService.resolveProject(pathCollectionEntry.getKey()); if (project == null) { continue; } if (!pendingNotifications.containsKey(project) && isObservableResource(pathCollectionEntry.getKey())) { pendingNotifications.put(project, pathCollectionEntry.getKey()); } else if (isPomFile(pathCollectionEntry.getKey())) { //if the pom.xml comes in the batch events set then use the pom.xml path for the cache invalidation event pendingNotifications.put(project, pathCollectionEntry.getKey()); } } for (final Map.Entry<Project, Path> pendingNotification : pendingNotifications.entrySet()) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOProjectCacheEvent(sessionInfo, pendingNotification.getKey(), pendingNotification.getValue())); } }
public void invalidateProjectCache(@Observes final InvalidateDMOModuleCacheEvent event) { PortablePreconditions.checkNotNull("event", event); final Path resourcePath = event.getResourcePath(); final KieModule module = moduleService.resolveModule(resourcePath); if (module != null) { invalidateCache(module); } } }
@Override public Path save( final Path resource, final String content, final Metadata metadata, final String comment ) { try { Metadata currentMetadata = metadataService.getMetadata( resource ); ioService.write( Paths.convert( resource ), content, metadataService.setUpAttributes( resource, metadata ), commentedOptionFactory.makeCommentedOption( comment ) ); //Invalidate Package-level DMO cache as a DSL has been altered invalidateDMOPackageCache.fire( new InvalidateDMOPackageCacheEvent( resource ) ); fireMetadataSocialEvents( resource, currentMetadata, metadata ); return resource; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } }
private void processBatchResourceChanges(final SessionInfo sessionInfo, final Map<Path, Collection<ResourceChange>> resourceChanges) { Module module; final Map<Module, Path> pendingNotifications = new HashMap<Module, Path>(); for (final Map.Entry<Path, Collection<ResourceChange>> pathCollectionEntry : resourceChanges.entrySet()) { //Only process Project resources module = projectService.resolveModule(pathCollectionEntry.getKey()); if (module == null) { continue; } if (!pendingNotifications.containsKey(module) && isObservableResource(pathCollectionEntry.getKey())) { pendingNotifications.put(module, pathCollectionEntry.getKey()); } else if (isPomFile(pathCollectionEntry.getKey())) { //if the pom.xml comes in the batch events set then use the pom.xml path for the cache invalidation event pendingNotifications.put(module, pathCollectionEntry.getKey()); } } for (final Map.Entry<Module, Path> pendingNotification : pendingNotifications.entrySet()) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, pendingNotification.getKey(), pendingNotification.getValue())); } }
@Override public void reImport(final Path pathToPomXML) { try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Path path = Paths.convert(projectDirectory); final Project project = resourceResolver.resolveProject(path); invalidateDMOCache.fire(new InvalidateDMOProjectCacheEvent(sessionInfo, project, path)); } catch (final Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { Metadata currentMetadata = metadataService.getMetadata(resource); ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); //Invalidate Package-level DMO cache as Enums have changed. invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); fireMetadataSocialEvents(resource, currentMetadata, metadata); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
private void processBatchResourceChanges(final SessionInfo sessionInfo, final Map<Path, Collection<ResourceChange>> resourceChanges) { Module module; final Map<Module, Path> pendingNotifications = new HashMap<Module, Path>(); for (final Map.Entry<Path, Collection<ResourceChange>> pathCollectionEntry : resourceChanges.entrySet()) { //Only process Project resources module = projectService.resolveModule(pathCollectionEntry.getKey()); if (module == null) { continue; } if (!pendingNotifications.containsKey(module) && isObservableResource(pathCollectionEntry.getKey())) { pendingNotifications.put(module, pathCollectionEntry.getKey()); } else if (isPomFile(pathCollectionEntry.getKey())) { //if the pom.xml comes in the batch events set then use the pom.xml path for the cache invalidation event pendingNotifications.put(module, pathCollectionEntry.getKey()); } } for (final Map.Entry<Module, Path> pendingNotification : pendingNotifications.entrySet()) { invalidateDMOProjectCacheEvent.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, pendingNotification.getKey(), pendingNotification.getValue())); } }
@Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { Metadata currentMetadata = metadataService.getMetadata(resource); ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); //Invalidate Package-level DMO cache as Enums have changed. invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); fireMetadataSocialEvents(resource, currentMetadata, metadata); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public void reImport(final Path pathToPomXML) { try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Path path = Paths.convert(projectDirectory); final Module module = resourceResolver.resolveModule(path); invalidateDMOCache.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } catch (final Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Override public Path save(final Path resource, final GlobalsModel content, final Metadata metadata, final String comment) { try { final Package pkg = moduleService.resolvePackage(resource); final String packageName = (pkg == null ? null : pkg.getPackageName()); content.setPackageName(packageName); Metadata currentMetadata = metadataService.getMetadata(resource); ioService.write(Paths.convert(resource), GlobalsPersistence.getInstance().marshal(content), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); //Invalidate Package-level DMO cache as Globals have changed. invalidatePackageDMOEvent.fire(new InvalidateDMOPackageCacheEvent(resource)); fireMetadataSocialEvents(resource, currentMetadata, metadata); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public void reImport(final Path pathToPomXML) { try { final org.uberfire.java.nio.file.Path projectDirectory = Paths.convert(pathToPomXML).getParent(); final Path path = Paths.convert(projectDirectory); final Module module = resourceResolver.resolveModule(path); invalidateDMOCache.fire(new InvalidateDMOModuleCacheEvent(sessionInfo, module, path)); } catch (final Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Test public void testCacheIsInvalidatedWhenResourceThatMapsToProject() { final InvalidateDMOModuleCacheEvent event = new InvalidateDMOModuleCacheEvent(sessionInfo, module, resourcePath); doReturn(module).when(moduleService).resolveModule(resourcePath); cache.invalidateProjectCache(event); verify(cache).invalidateCache(eq(module)); verify(cache, never()).invalidateCache(eq(otherModule)); } }